How can I apply a timeout to an Ant task?

陌路散爱 提交于 2019-12-08 19:21:19

问题


Without writing a custom Ant task, is there a way to use a timeout on a regular ant target?

To give some background info: we are using the 'delete' task to remove the contents of a given directory. Sometimes this directory is massive, with lots of generated folders and files. We wanted to have that task timeout after, say, 5 minutes.


回答1:


You might use the parallel task, which has a timeout, with a parallel degree of one:

<target name="timed_del">
    <parallel threadCount="1" timeout="300000">
        <sequential>
            ... your tasks here ...
        </sequential>
    </parallel>
</target>



回答2:


You can also use the limit task.

<target name="my-target">
  <limit seconds="2" failonerror="true">
    <sshexec ... />
  </limit>
</target>


来源:https://stackoverflow.com/questions/2463385/how-can-i-apply-a-timeout-to-an-ant-task

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