tags:

views:

59

answers:

2

Hi, I'm googling without success to figure out how to make ANT print System.out.println/System.out.print messages in the console. Messages simply don't appear. I haven't found any simple way of doing this. Is there any?

Thanks

+2  A: 

Use the echo task

<echo message="Hello, world"/>
<echo message="Hello, file" file="logfile.txt" />

If you want to read the output from a <java> task, use the outputproperty attribute:

<java ... outputproperty="javaoutput" />
<echo message="${javaoutput}" />
seanizer
This is not acceptable, I need to call `System.out.println()' from my application's code
denis_k
how are you running your code? with the `<java>` task?
seanizer
It is JUnit test that I execute with `<junit>` task
denis_k
Why do you put a `System.out.println` in your JUnit class then??
romaintaz
OK, couldn't find anything about that, I guess you'll have to find the junit generated output files and read them.
seanizer
@romaintaz: I need user who is executing ant task to see some testing internals in console during the build execution
denis_k
+2  A: 

The junit task printsummary attribute has a special setting withOutAndErr that:

is the same as on but also includes the output of the test as written to System.out and System.err.

Example use here.

martin clayton
+1 Thanks Martin, I did not know `junit task` print behavior could be overridden. BTW, task doc is here http://ant.apache.org/manual/Tasks/junit.html
unhillbilly
+1 Brilliant answer, exactly what I was looking for! Thanks!
denis_k