I had a similar need. I bassically created a shell script that would
generate a LIST property that contained a comma delimited list of
numbers. Here is the script...
#!/bin/bash
echo "How many POs?"
read NUM
X=0
echo -n "LIST=" >list.txt
while [ $X -lt $NUM ] ; do
if [ $X -lt 10 ] ; then
echo -n "$DELIM"00"$X" >> list.txt
elif [ $X -ge 10 ] & [ $X -lt 100 ] ; then
echo -n "$DELIM"0"$X" >> list.txt
else
echo -n "$DELIM""$X" >> list.txt
fi
DELIM=,
let X=$X+1
Done
Run this first to generate the LIST in list.txt, then use the foreach
task to loop over the LIST property in your build.xml. I know it's kinda
lame, but it works.
-Rob A
> -----Original Message-----
> From: Scot P. Floess [mailto:[EMAIL PROTECTED]
> Sent: Friday, June 09, 2006 3:50 AM
> To: Ant Users List
> Subject: Re: Implementing a loop in ANT
>
> They do, but unfortunately not exactly what Guru needs. They
> support for-loops over lists or file sets. Really, he needs
> something like:
>
> <for lower = "1" upper = "100">
> ...
> </for>
>
> I'm trying to figure out a way to do this using
> ant/ant-contrib but its not readily apparent to me (I though
> it'd be trivial) to make it happen.
>
> What I really need is some form of while loop. I considered
> using recursion...but I could see some possible issues with
> arbitrarily large iterations (not sure why one would do
> so...but nonetheless).
>
> Anyway, really I don't think he wants to pre-compute some
> large list with a delimiter and then use <for> over the
> list... At least I don't want to do that as a solution ;)
> Yes, I know one could possibly use a <script>. I am trying
> to not do that anyway (for reasons related to my open source
> project - long story)...
>
> Scot
>
> [EMAIL PROTECTED] wrote:
> > ant-contrib.sourceforge.net has some tasks to do this.
> >
> >
> >
> >
> > -----Original Message-----
> > From: "Guru Balse" <[EMAIL PROTECTED]>
> > Sent: Wed, June 7, 2006 2:17 pm
> > To: "Ant Users List" <[email protected]>
> > Subject: Implementing a loop in ANT
> >
> > I am sure this question has been asked before, and I could
> not see any
> > reasonable answer in the archives. How can I implement a
> loop in ANT
> > without using scripts? For example, if I want to call a certain
> > target N times, how can I do it?
> >
> > Using ant-contrib is OK. Of course, something like <for
> > list="1,2,3,4,5,6,...,N"> would work but I want N to be a property
> > that can be specified in the command line.
> >
> > Thanks in advance for your suggestions.
> >
> > - Guru Balse
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED] For
> additional
> > commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED] For
> additional
> > commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
>
> --
> Scot P. Floess
> 27 Lake Royale
> Louisburg, NC 27549
>
> 252-478-8087 (Home)
> 919-754-4592 (Work)
>
> Chief Architect JPlate http://sourceforge.net/projects/jplate
> Chief Architect JavaPIM http://sourceforge.net/projects/javapim
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED] For
> additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]