Wednesday, August 19, 2009

Redirect AntBuilder output in Groovy

In Groovy you can use the following code to redirect default AntBuilder output to a log file:


def ant = new AntBuilder()
def logOutput = new PrintStream(logFile)

// redirect std out and error output
System.out = logOutput
System.err = logOutput

// redirect ant output
ant.project.getBuildListeners().each{
it.setOutputPrintStream(logOutput)
}

1 comment:

fepede said...

Thanks for the post Nick!

it is exactly what I was googlin' for :)