Hi Manik -

I would suggest using antcall tasks in your script loop. For example:

<project name="projectName" default="main">
 <target name="echo">
   <echo message="This is my task to be repeated" />
 </target>

 <target name="script>
  <script language="javascript">
    for (i=0; i<10; i++)
    {
       antcallTask = projectName.createTask('antcall');
       main.addTask(antcallTask);
       // if needed
       antcallTask.init(); // this is required to pass params
       aParam = antcallTask.createParam();
       aParam.setName('foo');
       aParam.setValue('bar');
    }
  </script>
 </target>

 <target name="main" depends="script"/>
</project>


We are doing something similar to this in our build and it works quite
well. I did have some difficulties getting parameter passing to work,
and I don't recall whether the code I gave above is exactly right.

Good luck!

Peter


Manik Surtani wrote:
> 
> Hello, all.
> 
> I have noticed a problem with ant, and that is performing loops.
> 
> If I want a set of tasks to repeat several times based on a set of
> properties, the only way I can do this is using the <script> tags, and
> perform the loops in javascript.
> 
> Also, it is not possible to use the <script> tags to envelope a set of
> tasks to loop through, such as:
> 
> <script language="javascript">
> for (i=0; i<10; i++)
> {
> </script>
> 
> <echo message="This is my task to be repeated" />
> 
> <script language="javascript">
> }
> </script>
> 
> Instead, I have to create and execute the task in Javascript, which
> really takes away from the whole ANT XML build script thing.
> 
> My current J2EE build script runs almost everything in a loop, so this
> means almost the entire build.xml is just Javascript!!
> 
> Is there an alternate way to do this?
> 
> Also, who is the maintainer of the <script> tasks?  I am keen to know if
> such functionality (as described above) could be possible - I am
> volunteering to help develop the <script> task, but I need to get more
> famniliar with the task first.
> 
> Cheers,
> 
> --
> Manik Surtani
> Chief Technology Officer
> Silk Road Limited
> 
> Telephone: 07786 702 706
> Email: [EMAIL PROTECTED]
> Web: http://www.silkroad.co.uk
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to