B.16 ForeachTask
Prev | Appendix B. Core tasks | Next

## B.16 ForeachTask

The `foreach` task iterates over a list, a list of `filesets`, or both. If both, `list` and `filesets`, are specified, the list will be evaluated first. Nested `filesets` are evaluated in the order they appear in the task.

Table B.18: Attributes

Name | Type | Description | Default | Required
--- | --- | --- | --- | ---
`list` | `String` | The list of values to process, with the delimiter character, indicated by the "delimiter" attribute, separating each value. | n/a | No
`target` | `String` | The target to call for each token, passing the token as the parameter with the name indicated by the "param" attribute. | n/a | Yes
`param` | `String` | The name of the parameter to pass the tokens in as to the target. | n/a | Yes
`absparam` | `String` | The name of the absolute pathparameter to pass the tokens in as to the target (used while processing nested filesets). | n/a | No
`delimiter` | `String` | The delimiter string that separates the values in the "list" parameter. The default is ",". | , | No

### B.16.1 Examples

    <!-- loop through languages, and call buildlang task with setted param -->
    <property name="languages" value="en,fr,de" />
    <foreach list="${languages}" param="lang" target="buildlang" />

    <!-- loop through files, and call subtask task with set param and absparam -->
    <foreach param="filename" absparam="absfilename" target="subtask">
      <fileset dir=".">
        <include name="*.php"/>
      </fileset>
    </foreach>

### B.16.2 Supported Nested Tags

- `fileset`

- `filelist`

- `mapper`

Prev | Up | Next
B.15 FailTask | Home | B.17 IfTask