问题
Lord of all beginners here.
I'm trying to make a target in a build.xml that restarts itself when it meets a certain condition. I've searched high and low and I can't come up with a solution to make the target...well...loop. I'm stuck on this and it's driving me crazy, so any help is welcomed.
Edit: This is the target I want to loop:
<target name="prog" description="executes program">
<parallel>
<daemons>
<exec executable="mch" />
</daemons>
</parallel>
<exec executable="calculator" inputstring="$var">
<redirector output="log.txt" />
</exec>
<delete file="log.txt" />
</target>
The executable creates a file when it closes without finishing. So my loop condition would be if that file exists or not.
回答1:
Could you use waitfor task with checkevery
https://ant.apache.org/manual/Tasks/waitfor.html
Sounds similar to the example on the task page
<waitfor maxwait="3" maxwaitunit="minute" checkevery="500">
<http url="http://localhost/myapp/index.html"/>
</waitfor>
waits up to 3 minutes (and checks every 500 milliseconds) for a web server on localhost to serve up the specified URL.
回答2:
Solved the issue by using Repeat, an additional task from Antelope.
http://antelope.tigris.org/nonav/docs/manual/bk03ch24.html
来源:https://stackoverflow.com/questions/22483253/apache-ant-buildfile-looping