System.out with Ant

六月ゝ 毕业季﹏ 提交于 2019-12-10 02:14:15

问题


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


回答1:


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.




回答2:


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



回答3:


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>


来源:https://stackoverflow.com/questions/4042856/system-out-with-ant

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!