| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| |
| <HTML> |
| <HEAD> |
| <TITLE>FilterSet Type</TITLE> |
| <link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css"> |
| </HEAD> |
| |
| <BODY> |
| <H2><A name="filterset">FilterSet</A></H2> |
| |
| <P>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 <CODE><target></CODE> - i.e., as |
| children of |
| <CODE><project></CODE>.</P> |
| |
| <p>FilterSets support the <code>id</code> and <code>refid</code> |
| attributes. You can define a FilterSet with an <code>id</code> |
| attribute and then refer to that definition from another FilterSet |
| with a <code>refid</code> attribute. It is also possible to nest |
| filtersets into filtersets to get a set union of the contained |
| filters.</p> |
| |
| <p>In addition, FilterSets can specify |
| <code>begintoken</code> and/or |
| <code>endtoken</code> attributes to define what to match.</p> |
| <p>Filtersets are used for doing |
| replacements in tasks such as <code><copy></code>, etc.</p> |
| |
| <p> |
| <strong>Note: </strong>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. |
| </p> |
| |
| <H2>Filterset</H2> |
| |
| <TABLE cellSpacing=0 cellPadding=2 border=1> |
| <TR> |
| <TD vAlign=top><B>Attribute</B></TD> |
| <TD vAlign=top><B>Description</B></TD> |
| <TD vAlign=top><B>Default</B></TD> |
| <TD vAlign=top align="center"><B>Required</B></TD> |
| </TR> |
| <TR> |
| <TD vAlign=top>begintoken</TD> |
| <TD vAlign=top>The string marking the beginning of a token (eg., |
| <code>@DATE@</code>).</TD> |
| <TD vAlign=top>@</TD> |
| <TD vAlign=top align="center">No</TD> |
| </TR> |
| <TR> |
| <TD vAlign=top>endtoken</TD> |
| <TD vAlign=top>The string marking the end of a token (eg., |
| <code>@DATE@</code>).</TD> |
| <TD vAlign=top>@</TD> |
| <TD vAlign=top align="center">No</TD> |
| </TR> |
| </TABLE> |
| |
| <H2>Filter</H2> |
| <TABLE cellSpacing=0 cellPadding=2 border=1> |
| <TR> |
| <TD vAlign=top><B>Attribute</B></TD> |
| <TD vAlign=top><B>Description</B></TD> |
| <TD vAlign=top align="center"><B>Required</B></TD> |
| </TR> |
| <TR> |
| <TD vAlign=top>token</TD> |
| <TD vAlign=top>The token to replace (eg., <code>@DATE@</code>)</TD> |
| <TD vAlign=top align="center">Yes</TD> |
| </TR> |
| <TR> |
| <TD vAlign=top>value</TD> |
| <TD vAlign=top>The value to replace it with |
| (eg., <code>Thursday, April 26, 2001</code>).</TD> |
| <TD vAlign=top align="center">Yes</TD> |
| </TR> |
| </TABLE> |
| |
| <H2>Filtersfile</H2> |
| <TABLE cellSpacing=0 cellPadding=2 border=1> |
| <TR> |
| <TD vAlign=top><B>Attribute</B></TD> |
| <TD vAlign=top><B>Description</B></TD> |
| <TD vAlign=top align="center"><B>Required</B></TD> |
| </TR> |
| <TR> |
| <TD vAlign=top>file</TD> |
| <TD vAlign=top>A properties file of |
| name-value pairs from which to load the tokens.</TD> |
| <TD vAlign=top align="center">Yes</TD> |
| </TR> |
| </TABLE> |
| |
| <H4>Examples</H4> |
| |
| <p>You are copying the <code>version.txt</code> file to the <code>dist</code> |
| directory from the <code>build</code> directory |
| but wish to replace the token <code>@DATE@</code> with today's date.</p> |
| <BLOCKQUOTE><PRE> |
| <copy file="${build.dir}/version.txt" toFile="${dist.dir}/version.txt"> |
| <filterset> |
| <filter token="DATE" value="${TODAY}"/> |
| </filterset> |
| </copy> |
| </PRE></BLOCKQUOTE> |
| |
| <p>You are copying the <code>version.txt</code> file to the <code>dist</code> |
| directory from the build directory |
| but wish to replace the token <code>%DATE*</code> with today's date.</p> |
| <BLOCKQUOTE><PRE> |
| <copy file="${build.dir}/version.txt" toFile="${dist.dir}/version.txt"> |
| <filterset begintoken="%" endtoken="*"> |
| <filter token="DATE" value="${TODAY}"/> |
| </filterset> |
| </copy> |
| </PRE></BLOCKQUOTE> |
| |
| <p>Copy all the docs but change all dates and appropriate notices as stored in a file.</p> |
| <BLOCKQUOTE><PRE> |
| <copy toDir="${dist.dir}/docs"> |
| <fileset dir="${build.dir}/docs"> |
| <include name="**/*.html"> |
| </fileset> |
| <filterset begintoken="%" endtoken="*"> |
| <filtersfile file="${user.dir}/dist.properties"/> |
| </filterset> |
| </copy> |
| </PRE></BLOCKQUOTE> |
| |
| <p>Define a FilterSet and reference it later.</p> |
| <BLOCKQUOTE><PRE> |
| <filterset id="myFilterSet" begintoken="%" endtoken="*"> |
| <filter token="DATE" value="${TODAY}"/> |
| </filterset> |
| |
| <copy file="${build.dir}/version.txt" toFile="${dist.dir}/version.txt"> |
| <filterset refid="myFilterSet"/> |
| </copy> |
| </PRE></BLOCKQUOTE> |
| <HR> |
| |
| <P align=center>Copyright © 2001-2003 Apache Software Foundation. |
| All rights Reserved.</P></BODY></HTML> |