Guru:
Ah, I see your point and what you wish to do... Hmmm - have you
considered doing your own macro def to accomplish this?
I wasn't aware of the <math> task - I appreciate you pointing it out.
This functionality sorta inspires me, so I think I am going to
investigate writing my own macrodef to accomplish this type of
functionality. If you want, I'd be happy to send you what I create.
Take care,
Scot
Guru Balse wrote:
Thanks, Scot. You illustrate the problem quite well. The problem is
that N is defined as 9, but the loop only goes through 5 iterations :-(
Therefore unless we create a string on the fly using ${N} i.e. we
create ${list} as "1,2,3,4,5,6,7,8,9" using java script (or other
means) and then use <for list="${list}">, this will not work.
(Sigh!) I suppose something could be hacked together using <var> and
<math> (see
http://ant-contrib.sourceforge.net/tasks/tasks/math_task.html) ... I
was hoping for a more elegant solution :-)
Scot P. Floess wrote:
Sorry, my boldfaced was turned into *YYY*
Let me repost:
<project name = "test">
<taskdef resource = "net/sf/antcontrib/antlib.xml"/>
<for list="1,2,3,4,${N}" param = "val">
<sequential>
<echo message = "val = @{val}"/>
</sequential>
</for>
</project>
Command line:
ant -DN=9
Buildfile: build.xml
[echo] val = 1
[echo] val = 2
[echo] val = 3
[echo] val = 4
[echo] val = 9
BUILD SUCCESSFUL
Total time: 2 seconds
Scot P. Floess wrote:
Guru:
You should be able to do this like:
<for list="1,2,3,4,${N}">
Of course, assuming u do something like:
ant -DN=5 -f <your build.xml>
So, I wrote a simple test script as follows:
<project name = "test">
<taskdef resource = "net/sf/antcontrib/antlib.xml"/>
<for list="1,2,3,4,$*{N}*" param = "val">
<sequential>
<echo message = "val = @{val}"/>
</sequential>
</for>
</project>
When running I did/got this:
/home/sfloess/development/help/ant/guru> ant *-DN=9*
Buildfile: build.xml
[echo] val = 1
[echo] val = 2
[echo] val = 3
[echo] val = 4
[echo] val = 9
BUILD SUCCESSFUL
Total time: 2 seconds
Hope that helps...
Scot
Guru Balse wrote:
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]
--
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]