ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shatzer, Larry" <Larry.Shat...@Spirent.com>
Subject Macrodef and parallel in a recursive situation
Date Thu, 16 Oct 2003 20:32:28 GMT
I have run into a possible bug when working with macrodef and parallel in a
recursive situation.

The following build file snip example exhibits this: (This requires the <if>
ant-contrib task, and <math> from Antelope, soon to be ant-contrib).

  <macrodef name="recurse">
    <attribute name="until"/>
    <attribute name="current"/>
    <attribute name="method"/>
    <sequential>
      <if>
        <equals arg1="${until}" arg2="${current}"/>
        <then>
          <echo message="Method: ${method} done"/>
        </then>
        <else>
          <math
            datatype  = "int"
            operand1  = "${current}"
            operand2  = "1"
            operation = "+"
            result    = "newcurrent"
          />
          <echo
            message = "1: M: ${method}, C: ${current}, U: ${until}"
          />
          <sleep seconds="1"/>
          <echo
            message = "2: M: ${method}, C: ${current}, U: ${until}"
          />
          <recurse
            current = "${newcurrent}"
            method  = "${method}"
            until   = "${until}"
          />
        </else>
      </if>
    </sequential>
  </macrodef>
  
  <target name="test">
    <parallel>
      <recurse current="0" method="0" until="5"/>
      <recurse current="0" method="1" until="10"/>
      <recurse current="0" method="2" until="15"/>
      <recurse current="0" method="3" until="20"/>
    </parallel>
  </target>

Depending on the situation, this could result in an endless loop.

I use something similar to this method when checking out/updating a list of
cvs projects in parallel, and ran across the methoddef's steeping on each
others toes. I was converting from using antcall to macrodef.

I don't know how to handle this, since macrodef should be able to set and
read properties in a global context, but sometimes you want local variables.
Maybe add a flag to <attribute> of global/local?

-- Larry

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


Mime
View raw message