FilterSet是一组Filter的集合,那什么是Filter,这个词英文的意思是过滤。Filtersets are used for doing replacements in tasks such as <copy>
, etc.
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 |
看个例子:
<copy file="${build.dir}/version.txt" toFile="${dist.dir}/version.txt">
<filterset begintoken="%" endtoken="*">
<filter token="DATE" value="${TODAY}"/>
</filterset>
</copy>
copying theversion.txt
file to thedist
directory from the build directory but wish to replace the token%DATE*
with today's date.