## FilterSet

FilterSets are groups of filters. Filters can be defined as token-value pairs or be read in from a file. FilterSets can appear inside tasks that support this feature or at the same level as `<target>` - i.e., as children of `<project>`.

FilterSets support the `id` and `refid` attributes. You can define a FilterSet with an `id` attribute and then refer to that definition from another FilterSet with a `refid` attribute. It is also possible to nest filtersets into filtersets to get a set union of the contained filters.

In addition, FilterSets can specify `begintoken` and/or `endtoken` attributes to define what to match.

Filtersets are used for doing replacements in tasks such as `<copy>`, etc.

Note: When a filterset is used in an operation, the files are processed in text mode and the filters applied line by line. This means that the copy operations will typically corrupt binary files. When applying filters you should ensure that the set of files being filtered are all text files.

## Filterset

Attribute | Description | Default | Required
begintoken | The string marking the beginning of a token (eg., `@DATE@`). | @ | No
endtoken | The string marking the end of a token (eg., `@DATE@`). | @ | No
filtersfile | Specify a single filtersfile. | none | No
recurse | Indicates whether the replacement text of tokens should be searched for more tokens. Since Ant 1.6.3 | true | No
onmissingfiltersfile | Indicate behavior when a nonexistent filtersfile is specified. One of "fail", "warn", "ignore". Since Ant 1.7 | "fail" | No

## Filter

Attribute | Description | Required
token | The token to replace (eg., `@DATE@`) | Yes
value | The value to replace it with (eg., `Thursday, April 26, 2001`). | Yes

## Filtersfile

Attribute | Description | Required
file | A properties file of name-value pairs from which to load the tokens. | Yes

#### Examples

You are copying the `version.txt` file to the `dist` directory from the `build` directory but wish to replace the token `@DATE@` with today's date.

>     <copy file="build/version.txt" toFile="apache-ant-1.7.0/version.txt">
>       <filterset>
>         <filter token="DATE" value="December 13 2006"/>
>       </filterset>
>     </copy>

You are copying the `version.txt` file to the `dist` directory from the build directory but wish to replace the token `%DATE*` with today's date.

>     <copy file="build/version.txt" toFile="apache-ant-1.7.0/version.txt">
>       <filterset begintoken="%" endtoken="*">
>         <filter token="DATE" value="December 13 2006"/>
>       </filterset>
>     </copy>

Copy all the docs but change all dates and appropriate notices as stored in a file.

>     <copy toDir="apache-ant-1.7.0/docs">
>       <fileset dir="build/docs">
>         <include name="**/*.html">
>       </fileset>
>       <filterset begintoken="%" endtoken="*">
>         <filtersfile file="/Users/antoine/dev/asf/ant-core/dist.properties"/>
>       </filterset>
>     </copy>

Define a FilterSet and reference it later.

>     <filterset id="myFilterSet" begintoken="%" endtoken="*">
>       <filter token="DATE" value="December 13 2006"/>
>     </filterset>

>     <copy file="build/version.txt" toFile="apache-ant-1.7.0/version.txt">
>       <filterset refid="myFilterSet"/>
>     </copy>