ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guru Balse <guru.ba...@oracle.com>
Subject Re: For loop
Date Fri, 09 Jun 2006 20:01:57 GMT
Awesome, Scot.  It works well!  Can't wait for the "better" solution 
that you are about to create :-)
You must use 1.6.5 for this (for example, 1.6.2 did not work)

<project name="looper" default="test">
  <taskdef resource="net/sf/antcontrib/antcontrib.properties" 
classpath="/apache-ant-1.6.5ant1.6.2/lib/ant-contrib-1.0b1.jar"    />
  <macrodef  name = "jp-for">
      <attribute  name = "param"  description = "The name of the param 
containing the current value of the loop"/>
      <attribute  name = "lower"  default = "1"  description = "The 
lower bounds of the loop"/>
      <attribute  name = "upper"  description = "The upper bounds of the 
loop"/>
      <attribute  name = "step"   default = "1"  description = "The 
upper bounds of the loop"/>
      <element  name = "loop"  implicit = "true" description = "The 
enclosing block - just like ant contrib's for/sequential"/>
      <sequential>
          <var  name = "@{param}"  value = "@{lower}"/>
          <if><not><equals  arg1 = "${@{param}}"  arg2 = "@{upper}"/></not>
              <then>
                  <loop/>
                  <math  result = "@{param}"  datatype = "int"  
operation = "+"  operand1 = "${@{param}}"  operand2 = "@{step}"/>
                  <jp-for  param = "@{param}"  lower = "${@{param}}"  
upper = "@{upper}"  step = "@{step}">
                      <loop/>
                  </jp-for>
              </then>
          </if>
      </sequential>
  </macrodef>

  <target name="test">
    <jp-for param="outer" lower="0" upper="5">
      <jp-for param="inner" lower="0" upper="6">
          <echo> parameters are now: (${outer},${inner})</echo>
      </jp-for>
    </jp-for>
  </target>
</project>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message