Sunday, March 30, 2008

Generic retry target in ANT

I think the latest ANT trunk code has a new retry target. I wrote my own retry target using ANT 1.7 and ANT-contrib. It's kinda hackish, but it works well.
<target name="retry-task">
<var name="task.return" value="false" />
<for list="0,1,2" param="retry">
<equals arg1="${task.return}" arg2="false" />
<var name="task.return" value="true" />
<antcall target="${retry-target}"/>
<var name="task.return" value="false" />
<echo message="return ${task.return}" />
<equals arg1="${task.return}" arg2="false" />
<fail message="${retry-target} failed after 3 retries" />

To use this target:
<antcall target="retry-task">
<param name="retry-target" value="some-other-ant-task" />


Servidores said...
This comment has been removed by a blog administrator.
Julian said...

Hi there. Interesting post.

I don't use antcall or it's cousin 'call' in Nant in build files, but if you do, you want to make sure that the target that you call has no dependencies - well, if it does, you want to be happy with them being run again and again :)

More on my post at:



Anonymous said...

It is certainly interesting for me to read this article. Thanks for it. I like such topics and everything connected to them. I would like to read a bit more soon.