Title: RE: Foreach task...

Well I surprised myself and finished it off.
(Actually it was the thoughr that Stephan might do terrible things to me if he saw that I'd left his name in the code)

Documentation, a sample build file, and the (properly formated - I think) code.
Sorry no test case.

If anyone would like to commit it, please do so.
Otherwise, I'll find somewhere on the web to stick it in a week or so.

 

Attachment: build.xml
Description: Binary data

Attachment: ForeachTask.java
Description: Binary data

Title: Ant User Manual

Foreach

Description

Iterates over a set of parameter to call another target within the same build-file.

The set of parameters are joined to form a cartesian product, and the specified target is called once for each element in the resulting set.

Parameters

Attribute Description Required
target The target to execute. Yes

Parameters specified as nested elements

param

Specifies the properties to set before running the specified target.

Each <param> forms a set of parameters with a single property name

The elements in the parameter set can be taken from either a fileset or a list of <item> elements.

Examples

  <target name="default">
    <foreach target="compress">
      <param name="program">
        <item value="compress"/>
        <item value="gzip"/>
      </param>
      <param name="file">
        <fileset dir="." includes="**/*.tar"/>
      </param>
    </foreach>
  </target>

  <target name="compress">
    <exec executable="${program}">
      <arg file="${file}"/>
    </exec>
  </target>

Will pass each "tar" file through both "compress" and "gzip"


Copyright © 2000,2001 Apache Software Foundation. All rights Reserved.

Reply via email to