Search code examples
antant-contrib

How can I use ant-contrib for to do loop 500 times?


I need to do 500 times loop. Is there better way rather than

<property name="javato.activetesting.trialnum.list" value="0,1,2,...,500(terrible)" />

<for param="trialnum" list="${javato.activetesting.trialnum.list}">
   <sequential>
       <echo message="Sub-iteration:@{trialnum}" />
       <echo message="................" />
    </sequential>
</for>

I'm not sure how to progress this - any suggestions?


Solution

  • Antelope has an additional task called repeat which can be used like this:

     <taskdef name="repeat" classname="ise.antelope.tasks.Repeat"/>
     <repeat count="2" interval="1" unit="milliseconds">
         <echo>${count}</echo>
     </repeat>
    

    Also found this solution from another question:

    <target name="example4">
        <property name="n" value="3300"/>
        <property name="target" value="callee"/>
        <property name="param" value="calleeparam"/>
        <script language="javascript">
        // does n antcall's with iteration number param
        var n = parseInt(project.getProperty("n"),10);
        for (var i = 0; i &lt; n; i++) {
            var t = project.createTask("antcall");
            t.setTarget(project.getProperty("target"));
            var p = t.createParam();
            p.setName(project.getProperty("param"));
            p.setValue(""+i);
            t.perform();
        }
        </script>
    </target>