Tuesday, 13 January 2015

Ant - Running a task in a infinite loop

Ant is a task runner which by specifying different targets, it can run it and show the possible results.
Here is a trick to make it run a task in a infinite loop.

1. Download the antelope jar
1.1 Go to the home page of Antelope and download the antelope tasks jar. At the time of written this post the last version is 3.5.1
http://antelope.tigris.org/servlets/ProjectDocumentList?folderID=0&expandFolder=0&folderID=11184

1.2 Copy the jar file into the Ant library. For Mac OS X Yosemite it has the follow path:


/opt/local/share/java/apache-ant/lib

2. Config the Apache Ant build.xml
2.1 Open the build.xml of Apache ant and add the follow sentence on header, in the same line of project sentence:

xmlns:antelope="antlib:ise.antelope.tasks"

2.2 From the task you want to repeat, enclose it with the follow sentences:

<antelope:repeat count="-1">
    <!-- Tasks go here -->
</antelope:repeat> 

Note that optionally you could save the jar file download in the step 1 to another directory. In that case you should execute the ant command with -lib option. For instance:

ant mySuperCoolTask -lib PATH_TO_ANTELOP_LIBRARY

In case you want to just loop a finite number of times, just replace -1 of the step 2.2 with the number of loops you want to run.

The repeat command also has several options. Check the official manual for more information:

Source

No comments:

Post a Comment