Apache ant buildfile looping

2019-06-14 02:36发布

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.

2条回答
Luminary・发光体
2楼-- · 2019-06-14 03:14

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.
查看更多
\"骚年 ilove
3楼-- · 2019-06-14 03:16

Solved the issue by using Repeat, an additional task from Antelope.

http://antelope.tigris.org/nonav/docs/manual/bk03ch24.html

查看更多
登录 后发表回答