简体   繁体   English

System.out与Ant

[英]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. 我正在谷歌搜索以弄清楚如何使ANT在控制台中打印System.out.println/System.out.print消息。 Messages simply don't appear. 消息根本不会出现。 I haven't found any simple way of doing this. 我还没有找到任何简单的方法来做到这一点。 Is there any? 有没有?

Thanks 谢谢

The junit task printsummary attribute has a special setting withOutAndErr that: junit任务的printsummary属性具有一个特殊的withOutAndErr设置,该设置withOutAndErr

is the same as on but also includes the output of the test as written to System.out and System.err. 与on相同,但还包括写入System.out和System.err的测试输出。

Use the echo task 使用echo任务

<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属性:

<java ... outputproperty="javaoutput" />
<echo message="${javaoutput}" />

Another cause for not seeing standard output from your program is if you have forked the java process. 无法从程序中看到标准输出的另一个原因是您是否分叉了Java进程。

This will happen if you are using the Java task and have chosen to fork the execution to another VM: 如果您正在使用Java任务并选择将执行分叉到另一个VM,则会发生这种情况:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM