System.out with Ant

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

Upvotes: 11

Views: 8982

Answers (3)

martin clayton
martin clayton

Reputation: 78155

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.

Upvotes: 11

matt burns
matt burns

Reputation: 25400

Another cause for not seeing standard output from your program is if you have forked the java process.

This will happen if you are using the Java task and have chosen to fork the execution to another VM:

<java classname="com.example.MyClass" fork="true">
    ...
</java>

Upvotes: 2

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 299048

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}" />

Upvotes: 7

Related Questions