1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 |
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <title>FilterSet Type</title>
|
---|
6 | <link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
|
---|
7 | </head>
|
---|
8 |
|
---|
9 | <body>
|
---|
10 | <h2><a name="filterset">FilterSet</a></h2>
|
---|
11 |
|
---|
12 | <p>FilterSets are groups of filters. Filters can be defined as token-value
|
---|
13 | pairs
|
---|
14 | or be read in from a file. FilterSets can appear inside tasks that support this
|
---|
15 | feature or at the same level as <code><target></code> - i.e., as
|
---|
16 | children of
|
---|
17 | <code><project></code>.</p>
|
---|
18 |
|
---|
19 | <p>FilterSets support the <code>id</code> and <code>refid</code>
|
---|
20 | attributes. You can define a FilterSet with an <code>id</code>
|
---|
21 | attribute and then refer to that definition from another FilterSet
|
---|
22 | with a <code>refid</code> attribute. It is also possible to nest
|
---|
23 | filtersets into filtersets to get a set union of the contained
|
---|
24 | filters.</p>
|
---|
25 |
|
---|
26 | <p>In addition, FilterSets can specify
|
---|
27 | <code>begintoken</code> and/or
|
---|
28 | <code>endtoken</code> attributes to define what to match.</p>
|
---|
29 | <p>Filtersets are used for doing
|
---|
30 | replacements in tasks such as <code><copy></code>, etc.</p>
|
---|
31 |
|
---|
32 | <p>
|
---|
33 | <strong>Note: </strong>When a filterset is used in an operation, the files are
|
---|
34 | processed in text mode and the filters applied line by line. This means that
|
---|
35 | the copy operations will typically corrupt binary files. When applying filters
|
---|
36 | you should ensure that the set of files being filtered are all text files.
|
---|
37 | </p>
|
---|
38 |
|
---|
39 | <h2>Filterset</h2>
|
---|
40 |
|
---|
41 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
42 | <tr>
|
---|
43 | <td vAlign=top><b>Attribute</b></td>
|
---|
44 | <td vAlign=top><b>Description</b></td>
|
---|
45 | <td vAlign=top><b>Default</b></td>
|
---|
46 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
47 | </tr>
|
---|
48 | <tr>
|
---|
49 | <td vAlign=top>begintoken</td>
|
---|
50 | <td vAlign=top>The string marking the beginning of a token (eg.,
|
---|
51 | <code>@DATE@</code>).</td>
|
---|
52 | <td vAlign=top>@</td>
|
---|
53 | <td vAlign=top align="center">No</td>
|
---|
54 | </tr>
|
---|
55 | <tr>
|
---|
56 | <td vAlign=top>endtoken</td>
|
---|
57 | <td vAlign=top>The string marking the end of a token (eg.,
|
---|
58 | <code>@DATE@</code>).</td>
|
---|
59 | <td vAlign=top>@</td>
|
---|
60 | <td vAlign=top align="center">No</td>
|
---|
61 | </tr>
|
---|
62 | <tr>
|
---|
63 | <td vAlign=top>recurse</td>
|
---|
64 | <td vAlign=top>Indicates whether the replacement text of tokens
|
---|
65 | should be searched for more tokens. <b>Since Ant 1.6.3</b></td>
|
---|
66 | <td vAlign=top><i>true</i></td>
|
---|
67 | <td vAlign=top align="center">No</td>
|
---|
68 | </tr>
|
---|
69 | </table>
|
---|
70 |
|
---|
71 | <h2>Filter</h2>
|
---|
72 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
73 | <tr>
|
---|
74 | <td vAlign=top><b>Attribute</b></td>
|
---|
75 | <td vAlign=top><b>Description</b></td>
|
---|
76 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
77 | </tr>
|
---|
78 | <tr>
|
---|
79 | <td vAlign=top>token</td>
|
---|
80 | <td vAlign=top>The token to replace (eg., <code>@DATE@</code>)</td>
|
---|
81 | <td vAlign=top align="center">Yes</td>
|
---|
82 | </tr>
|
---|
83 | <tr>
|
---|
84 | <td vAlign=top>value</td>
|
---|
85 | <td vAlign=top>The value to replace it with
|
---|
86 | (eg., <code>Thursday, April 26, 2001</code>).</td>
|
---|
87 | <td vAlign=top align="center">Yes</td>
|
---|
88 | </tr>
|
---|
89 | </table>
|
---|
90 |
|
---|
91 | <h2>Filtersfile</h2>
|
---|
92 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
93 | <tr>
|
---|
94 | <td vAlign=top><b>Attribute</b></td>
|
---|
95 | <td vAlign=top><b>Description</b></td>
|
---|
96 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
97 | </tr>
|
---|
98 | <tr>
|
---|
99 | <td vAlign=top>file</td>
|
---|
100 | <td vAlign=top>A properties file of
|
---|
101 | name-value pairs from which to load the tokens.</td>
|
---|
102 | <td vAlign=top align="center">Yes</td>
|
---|
103 | </tr>
|
---|
104 | </table>
|
---|
105 |
|
---|
106 | <h4>Examples</h4>
|
---|
107 |
|
---|
108 | <p>You are copying the <code>version.txt</code> file to the <code>dist</code>
|
---|
109 | directory from the <code>build</code> directory
|
---|
110 | but wish to replace the token <code>@DATE@</code> with today's date.</p>
|
---|
111 | <blockquote><pre>
|
---|
112 | <copy file="${build.dir}/version.txt" toFile="${dist.dir}/version.txt">
|
---|
113 | <filterset>
|
---|
114 | <filter token="DATE" value="${TODAY}"/>
|
---|
115 | </filterset>
|
---|
116 | </copy>
|
---|
117 | </pre></blockquote>
|
---|
118 |
|
---|
119 | <p>You are copying the <code>version.txt</code> file to the <code>dist</code>
|
---|
120 | directory from the build directory
|
---|
121 | but wish to replace the token <code>%DATE*</code> with today's date.</p>
|
---|
122 | <blockquote><pre>
|
---|
123 | <copy file="${build.dir}/version.txt" toFile="${dist.dir}/version.txt">
|
---|
124 | <filterset begintoken="%" endtoken="*">
|
---|
125 | <filter token="DATE" value="${TODAY}"/>
|
---|
126 | </filterset>
|
---|
127 | </copy>
|
---|
128 | </pre></blockquote>
|
---|
129 |
|
---|
130 | <p>Copy all the docs but change all dates and appropriate notices as stored in a file.</p>
|
---|
131 | <blockquote><pre>
|
---|
132 | <copy toDir="${dist.dir}/docs">
|
---|
133 | <fileset dir="${build.dir}/docs">
|
---|
134 | <include name="**/*.html">
|
---|
135 | </fileset>
|
---|
136 | <filterset begintoken="%" endtoken="*">
|
---|
137 | <filtersfile file="${user.dir}/dist.properties"/>
|
---|
138 | </filterset>
|
---|
139 | </copy>
|
---|
140 | </pre></blockquote>
|
---|
141 |
|
---|
142 | <p>Define a FilterSet and reference it later.</p>
|
---|
143 | <blockquote><pre>
|
---|
144 | <filterset id="myFilterSet" begintoken="%" endtoken="*">
|
---|
145 | <filter token="DATE" value="${TODAY}"/>
|
---|
146 | </filterset>
|
---|
147 |
|
---|
148 | <copy file="${build.dir}/version.txt" toFile="${dist.dir}/version.txt">
|
---|
149 | <filterset refid="myFilterSet"/>
|
---|
150 | </copy>
|
---|
151 | </pre></blockquote>
|
---|
152 | <hr>
|
---|
153 |
|
---|
154 | <p align=center>Copyright © 2001-2005 The Apache Software Foundation.
|
---|
155 | All rights Reserved.</p></body></html>
|
---|