
在Ant exec任务中设置timeout属性并且任务超时时,是否有办法检测超时?我没有看到任何有用的结果,输出或错误属性,表明超时.
解决方法:
当<exec>由于超时而导致子进程被杀死时,父Ant进程会记录消息Timeout:kill the sub-process.但是,由于< exec>重定向器仅捕获子进程的输出,并且< exec>中没有超时的指示. outputProperty或errorProperty.
要设置指示子进程超时的属性,可以使用<record>任务捕获Ant的日志输出,如以下示例所示.
<target name="exec-timeout"> <record name="exec.log" action="start" /> <exec executable="java" timeout="1500"> <arg line="-jar /path/to/executable.jar" /> </exec> <record name="exec.log" action="stop" /> <condition property="timed-out" else="false"> <resourcecontains resource="exec.log" substring="Timeout: killed the sub-process" /> </condition> <delete file="exec.log" /> <echo message="exec timed out: ${timed-out}" /></target>产量
exec-timeout: [exec] Timeout: killed the sub-process [exec] Result: 143 [echo] exec timed out: trueBUILD SUCCESSFulTotal time: 2 seconds 总结 以上是内存溢出为你收集整理的java – 检测Ant exec任务中的超时全部内容,希望文章能够帮你解决java – 检测Ant exec任务中的超时所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)