ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot P. Floess" <flo...@mindspring.com>
Subject Re: Implementing a loop in ANT
Date Wed, 07 Jun 2006 23:56:47 GMT
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: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

-- 
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


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message