Peter,

I hate to burst your bubble, but you've broken backward compatibility
of the <foreach> task.

The following no longer parses correctly:

<foreach list="1,2,3" param="value" target="do.something">
  <param name="additional.parameter" value="${some.value}" />
</foreach>

I tried adding a createParam() method to the ForEach task, but
once you made it extend taskcontainer, it no longer can contain
elements that aren't tasks apparantly, so it says that the
<param> nested element is not supported.

Any idea how to fix it?


-----Original Message-----
From: peter reilly [mailto:peter.reilly@corvil.com]
Sent: Wednesday, October 08, 2003 5:13 AM
To: ant-contrib-developers@lists.sourceforge.net
Subject: Re: [Ant-contrib-developers] foreach


I am preparing a modified version of <foreach/> which
allows a <sequential/> element in place  of a target.

Example:

<target name="sequential">
    <foreach param="x" list="a,b,c">
      <sequential>
        <echo>${x}</echo>
      </sequential>
    <foreach>
    <echo>x is ${x}</echo>
</target>

It depends on ant 1.6. It does not use antcall
under the hood. The sequential is run in the same
project as the foreach task.

It has gone through three implementations:

1) Just use properties:

   This is the simplest implementation, but it does override
   the property used for the loop and depends on
   undefined behaviour in core ant.

   In the example above the output would be:

sequential:
     [echo] a
     [echo] b
     [echo] c
     [echo] x is c
 
   The idea for this came from antattack.

2) Copy the code from MacroInstance
 
   This involves clone and modifing unknown elements and runtime
   configuration objects. This gives the result:

sequential:
     [echo] a
     [echo] b
     [echo] c
     [echo] x is ${x}

   The problem with this implementation is that it needs to have a lot
   of knowledge of ant core objects. These objects will most likely change
   in future versions of ant (new attributes for example).

3) use MacroDef and MacroInstance objects
   This is the current implementation. I had to make a small modification to
   MacroInstance to make the setMacroDef method of MacroInstance public (it
   was protected).
   The nice thing about this implementation is that it relies on a small set
   of (now) public methods so it should be resilient to future changes in
   ant.

Since the changes are dependent on ant 1.6 (next beta), I have not yet placed
the modifed foreach in cvs, but would like some feed-back as to when I
should do this.

Peter



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Ant-contrib-developers mailing list
Ant-contrib-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ant-contrib-developers