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.

In addition, Filtersets can have begintoken and/or endtoken attributes to define what to match.
Filtersets are used for doing replacements in tasks like copy etc.

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

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 The file to load tokens from should be a properties file of name value pairs. Yes

Examples

You are copying the version.txt file to the dist directory from the build directory but wish to replace the token July 31 2002 with todays date.

<copy file="${build.home}/version.txt" toFile="${dist.home}/version.txt">
  <filterset>
    <filter token="DATE" value="${DATE}"/>
  </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 todays date.

<copy file="${build.home}/version.txt" toFile="${dist.home}/version.txt">
  <filterset begintoken="%" endtoken="*">
    <filter token="DATE" value="${DATE}"/>
  </filterset>
</copy>

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

<copy toDir="${dist.home}/docs" >
  <fileset dir="${build.home}/docs">
    <include name="**/*.html">
  </fileset>
  <filterset begintoken="%" endtoken="*">
    <filter token="DATE" value="${DATE}"/>
    <filtersfile file="${user.home}/dist.properties"/>
  </filterset>
</copy>

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