|
Directing output groovy ant task to a file |
|
Facts -
Java
|
|
Wednesday, 20 August 2008 21:10 |
|
You should be able to use the output attribute to direct the output of a groovy ant task to a file:
<groovy output="logFile.txt">
.....
</groovy>
I could not get this working with groovy version 1.5.6 though. So I use the following statements
within my groovy code to direct the standard output to a file:
def stdOut = System.out; // save old System.out
def newFileOutputStream = new FileOutputStream("myLogFile.txt", true);
def newOutputFilePrintSteam = new PrintStream(newFileOutputStream);
System.setOut(newOutputFilePrintSteam);
...............
System.setOut(stdOut); // go back to default standard out
The first and the last statement prevent other groovy tasks in your ant build file logging to the
same file.
|