source: release-kits/lirk3/bin/ant-installer/web/manual1.7.0/manual/CoreTypes/selectors.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 57.5 KB
Line 
1<!--
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<html>
18 <head>
19 <meta http-equiv="Content-Language" content="en-us">
20 <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
21<title>Selectors in Ant</title>
22 </head>
23
24 <body>
25 <h2>Selectors</h2>
26
27 <p>Selectors are a mechanism whereby the files that make up a
28 <code>&lt;fileset&gt;</code> can be selected based on criteria
29 other than filename as provided by the <code>&lt;include&gt;</code>
30 and <code>&lt;exclude&gt;</code> tags.</p>
31
32 <h3>How to use a Selector</h3>
33
34 <p>A selector is an element of FileSet, and appears within it. It can
35 also be defined outside of any target by using the <code>&lt;selector&gt;</code> tag
36 and then using it as a reference.
37 </p>
38
39 <p>Different selectors have different attributes. Some selectors can
40 contain other selectors, and these are called
41 <a href="#selectcontainers"><code>Selector Containers</code></a>.
42 There is also a category of selectors that allow
43 user-defined extensions, called
44 <a href="#customselect"><code>Custom Selectors</code></a>.
45 The ones built in to Ant are called
46 <a href="#coreselect"><code>Core Selectors</code></a>.
47 </p>
48
49 <a name="coreselect"></a>
50 <h3>Core Selectors</h3>
51
52 <p>Core selectors are the ones that come standard
53 with Ant. They can be used within a fileset and can be contained
54 within Selector Containers.</p>
55
56 <p>The core selectors are:</p>
57
58 <ul>
59 <li><a href="#containsselect"><code>&lt;contains&gt;</code></a> - Select
60 files that contain a particular text string</li>
61 <li><a href="#dateselect"><code>&lt;date&gt;</code></a> - Select files
62 that have been modified either before or after a particular date
63 and time</li>
64 <li><a href="#dependselect"><code>&lt;depend&gt;</code></a> - Select files
65 that have been modified more recently than equivalent files
66 elsewhere</li>
67 <li><a href="#depthselect"><code>&lt;depth&gt;</code></a> - Select files
68 that appear so many directories down in a directory tree</li>
69 <li><a href="#differentselect"><code>&lt;different&gt;</code></a> - Select files
70 that are different from those elsewhere</li>
71 <li><a href="#filenameselect"><code>&lt;filename&gt;</code></a> - Select
72 files whose name matches a particular pattern. Equivalent to
73 the include and exclude elements of a patternset.</li>
74 <li><a href="#presentselect"><code>&lt;present&gt;</code></a> - Select
75 files that either do or do not exist in some other location</li>
76 <li><a href="#regexpselect"><code>&lt;containsregexp&gt;</code></a> - Select
77 files that match a regular expression</li>
78 <li><a href="#sizeselect"><code>&lt;size&gt;</code></a> - Select files
79 that are larger or smaller than a particular number of bytes.</li>
80 <li><a href="#typeselect"><code>&lt;type&gt;</code></a> - Select files
81 that are either regular files or directories.</li>
82 <li><a href="#modified"><code>&lt;modified&gt;</code></a> - Select files if
83 the return value of the configured algorithm is different from that
84 stored in a cache.</li>
85 <li><a href="#signedselector"><code>&lt;signedselector&gt;</code></a> - Select files if
86 they are signed, and optionally if they have a signature of a certain name.
87 </li>
88 <li><a href="#scriptselector"><code>&lt;scriptselector&gt;</code></a> -
89 Use a BSF or JSR 223 scripting language to create
90 your own selector
91 </li>
92 </ul>
93
94 <a name="containsselect"></a>
95 <h4>Contains Selector</h4>
96
97 <p>The <code>&lt;contains&gt;</code> tag in a FileSet limits
98 the files defined by that fileset to only those which contain the
99 string specified by the <code>text</code> attribute.
100 .</p>
101 <p>The <code>&lt;contains&gt;</code> selector can be used as a
102 ResourceSelector (see the
103 <a href="resources.html#restrict">&lt;restrict&gt;</a>
104 ResourceCollection).</p>
105
106 <table border="1" cellpadding="2" cellspacing="0">
107 <tr>
108 <td valign="top"><b>Attribute</b></td>
109 <td valign="top"><b>Description</b></td>
110 <td align="center" valign="top"><b>Required</b></td>
111 </tr>
112 <tr>
113 <td valign="top">text</td>
114 <td valign="top">Specifies the text that every file must contain
115 </td>
116 <td valign="top" align="center">Yes</td>
117 </tr>
118 <tr>
119 <td valign="top">casesensitive</td>
120 <td valign="top">Whether to pay attention to case when looking
121 for the string in the <code>text</code> attribute. Default is
122 true.
123 </td>
124 <td valign="top" align="center">No</td>
125 </tr>
126 <tr>
127 <td valign="top">ignorewhitespace</td>
128 <td valign="top">Whether to eliminate whitespace before checking
129 for the string in the <code>text</code> attribute. Default is
130 false.
131 </td>
132 <td valign="top" align="center">No</td>
133 </tr>
134 </table>
135
136 <p>Here is an example of how to use the Contains Selector:</p>
137
138 <blockquote><pre>
139&lt;fileset dir=&quot;${doc.path}&quot; includes=&quot;**/*.html&quot;&gt;
140 &lt;contains text=&quot;script&quot; casesensitive=&quot;no&quot;/&gt;
141&lt;/fileset&gt;
142</pre></blockquote>
143
144 <p>Selects all the HTML files that contain the string
145 <code>script</code>.</p>
146
147
148 <a name="dateselect"></a>
149 <h4>Date Selector</h4>
150
151 <p>The <code>&lt;date&gt;</code> tag in a FileSet will put
152 a limit on the files specified by the include tag, so that tags
153 whose last modified date does not meet the date limits specified
154 by the selector will not end up being selected.</p>
155
156 <table border="1" cellpadding="2" cellspacing="0">
157 <tr>
158 <td valign="top"><b>Attribute</b></td>
159 <td valign="top"><b>Description</b></td>
160 <td align="center" valign="top"><b>Required</b></td>
161 </tr>
162 <tr>
163 <td valign="top">datetime</td>
164 <td valign="top">Specifies the date and time to test for.
165 Should be in the format MM/DD/YYYY HH:MM AM_or_PM, or
166 an alternative pattern specified via the <i>pattern</i>
167 attribute.
168 </td>
169 <td valign="top" align="center" rowspan="2">At least one of the two.</td>
170 </tr>
171 <tr>
172 <td valign="top">millis</td>
173 <td valign="top">The number of milliseconds since 1970 that should
174 be tested for. It is usually much easier to use the datetime
175 attribute.
176 </td>
177 </tr>
178 <tr>
179 <td valign="top">when</td>
180 <td valign="top">Indicates how to interpret the date, whether
181 the files to be selected are those whose last modified times should
182 be before, after, or equal to the specified value. Acceptable
183 values for this attribute are:
184 <ul>
185 <li>before - select files whose last modified date is before the indicated date
186 <li>after - select files whose last modified date is after the indicated date
187 <li>equal - select files whose last modified date is this exact date
188 </ul>
189 The default is equal.
190 <td valign="top" align="center">No</td>
191 </tr>
192 <tr>
193 <td valign="top">granularity</td>
194 <td valign="top">The number of milliseconds leeway to use when
195 comparing file modification times. This is needed because not every
196 file system supports tracking the last modified time to the
197 millisecond level. Default is 0 milliseconds, or 2 seconds on DOS systems.
198 </td>
199 <td valign="top" align="center">No</td>
200 </tr>
201 <tr>
202 <td valign="top">pattern</td>
203 <td valign="top">The <CODE>SimpleDateFormat</CODE>-compatible pattern
204 to use when interpreting the <i>datetime</i> attribute.
205 <i>Since Ant 1.6.2</i>
206 </td>
207 <td valign="top" align="center">No</td>
208 </tr>
209 <tr>
210 <td valign="top">checkdirs</td>
211 <td valign="top">
212 Indicates whether or not to check dates on directories.
213 </td>
214 <td valign="top" align="center">No, defaults to <i>false</i></td>
215 </tr>
216 </table>
217
218 <p>Here is an example of how to use the Date Selector:</p>
219
220 <blockquote><pre>
221&lt;fileset dir=&quot;${jar.path}&quot; includes=&quot;**/*.jar&quot;&gt;
222 &lt;date datetime=&quot;01/01/2001 12:00 AM&quot; when=&quot;before&quot;/&gt;
223&lt;/fileset&gt;
224</pre></blockquote>
225
226 <p>Selects all JAR files which were last modified before midnight
227 January 1, 2001.</p>
228
229
230 <a name="dependselect"></a>
231 <h4>Depend Selector</h4>
232
233 <p>The <code>&lt;depend&gt;</code> tag selects files
234 whose last modified date is later than another, equivalent file in
235 another location.</p>
236
237 <p>The <code>&lt;depend&gt;</code> tag supports the use of a
238 contained <a href="mapper.html"><code>&lt;mapper&gt;</code></a> element
239 to define the location of the file to be compared against. If no
240 <code>&lt;mapper&gt;</code> element is specified, the
241 <code>identity</code> type mapper is used.</p>
242
243 <p>The <code>&lt;depend&gt;</code> selector is case-sensitive.</p>
244
245 <table border="1" cellpadding="2" cellspacing="0">
246 <tr>
247 <td valign="top"><b>Attribute</b></td>
248 <td valign="top"><b>Description</b></td>
249 <td align="center" valign="top"><b>Required</b></td>
250 </tr>
251 <tr>
252 <td valign="top">targetdir</td>
253 <td valign="top">The base directory to look for the files to compare
254 against. The precise location depends on a combination of this
255 attribute and the <code>&lt;mapper&gt;</code> element, if any.
256 </td>
257 <td valign="top" align="center">Yes</td>
258 </tr>
259 <tr>
260 <td valign="top">granularity</td>
261 <td valign="top">The number of milliseconds leeway to give before
262 deciding a file is out of date. This is needed because not every
263 file system supports tracking the last modified time to the
264 millisecond level. Default is 0 milliseconds, or 2 seconds on DOS systems.
265 </td>
266 <td valign="top" align="center">No</td>
267 </tr>
268 </table>
269
270 <p>Here is an example of how to use the Depend Selector:</p>
271
272 <blockquote><pre>
273&lt;fileset dir=&quot;${ant.1.5}/src/main&quot; includes=&quot;**/*.java&quot;&gt;
274 &lt;depend targetdir=&quot;${ant.1.4.1}/src/main&quot;/&gt;
275&lt;/fileset&gt;
276</pre></blockquote>
277
278 <p>Selects all the Java source files which were modified in the
279 1.5 release.
280 </p>
281
282
283 <a name="depthselect"></a>
284 <h4>Depth Selector</h4>
285
286 <p>The <code>&lt;depth&gt;</code> tag selects files based on
287 how many directory levels deep they are in relation to the base
288 directory of the fileset.
289 </p>
290
291 <table border="1" cellpadding="2" cellspacing="0">
292 <tr>
293 <td valign="top"><b>Attribute</b></td>
294 <td valign="top"><b>Description</b></td>
295 <td align="center" valign="top"><b>Required</b></td>
296 </tr>
297 <tr>
298 <td valign="top">min</td>
299 <td valign="top">The minimum number of directory levels below
300 the base directory that a file must be in order to be selected.
301 Default is no limit.
302 </td>
303 <td valign="top" align="center" rowspan="2">At least one of the two.</td>
304 </tr>
305 <tr>
306 <td valign="top">max</td>
307 <td valign="top">The maximum number of directory levels below
308 the base directory that a file can be and still be selected.
309 Default is no limit.
310 </td>
311 </tr>
312 </table>
313
314 <p>Here is an example of how to use the Depth Selector:</p>
315
316 <blockquote><pre>
317&lt;fileset dir=&quot;${doc.path}&quot; includes=&quot;**/*&quot;&gt;
318 &lt;depth max=&quot;1&quot;/&gt;
319&lt;/fileset&gt;
320</pre></blockquote>
321
322 <p>Selects all files in the base directory and one directory below
323 that.</p>
324
325 <a name="differentselect"></a>
326 <h4>Different Selector</h4>
327
328 <p>The <code>&lt;different&gt;</code> selector will select a file
329 if it is deemed to be 'different' from an equivalent file in
330 another location. The rules for determining difference between
331 the two files are as follows:
332 <ol>
333 <li> If there is no 'other' file, it's different.
334 <li> Files with different lengths are different.
335 <li> If <tt>ignoreFileTimes</tt> is turned off, then differing file
336 timestamps will cause files to be regarded as different.
337 <li> Unless <tt>ignoreContents</tt> is set to true,
338 a byte-for-byte check is run against the two files.
339 </ol>
340
341 This is a useful selector to work with programs and tasks that don't handle
342 dependency checking properly; even if a predecessor task always creates its
343 output files, followup tasks can be driven off copies made with a different
344 selector, so their dependencies are driven on the absolute state of the
345 files, not just a timestamp. For example: anything fetched from a web site,
346 or the output of some program. To reduce the amount of checking, when using
347 this task inside a <code>&lt;copy&gt;</code> task, set
348 <tt>preservelastmodified</tt> to <i>true</i> to propagate the timestamp
349 from the source file to the destination file.<p>
350
351 The <code>&lt;different&gt;</code> selector supports the use of a
352 contained <a href="mapper.html"><code>&lt;mapper&gt;</code></a> element
353 to define the location of the file to be compared against. If no
354 <code>&lt;mapper&gt;</code> element is specified, the
355 <code>identity</code> type mapper is used.</p>
356
357 <table border="1" cellpadding="2" cellspacing="0">
358 <tr>
359 <td valign="top"><b>Attribute</b></td>
360 <td valign="top"><b>Description</b></td>
361 <td align="center" valign="top"><b>Required</b></td>
362 </tr>
363 <tr>
364 <td valign="top">targetdir</td>
365 <td valign="top">The base directory to look for the files to compare
366 against. The precise location depends on a combination of this
367 attribute and the <code>&lt;mapper&gt;</code> element, if any.
368 </td>
369 <td valign="top" align="center">Yes</td>
370 </tr>
371 <tr>
372 <td valign="top">ignoreFileTimes</td>
373 <td valign="top">Whether to use file times in the comparison or not.
374 Default is true (time differences are ignored).
375 </td>
376 <td valign="top" align="center">No</td>
377 </tr>
378 <tr>
379 <td valign="top">ignoreContents</td>
380 <td valign="top">Whether to do a byte per byte compare.
381 Default is false (contents are compared).
382 Since Ant 1.6.3
383 </td>
384 <td valign="top" align="center">No</td>
385 </tr>
386 <tr>
387 <td valign="top">granularity</td>
388 <td valign="top">The number of milliseconds leeway to give before
389 deciding a file is out of date. This is needed because not every
390 file system supports tracking the last modified time to the
391 millisecond level. Default is 0 milliseconds, or 2 seconds on DOS systems.
392 </td>
393 <td valign="top" align="center">No</td>
394 </tr>
395 </table>
396
397 <p>Here is an example of how to use the Different Selector:</p>
398
399 <blockquote><pre>
400&lt;fileset dir=&quot;${ant.1.5}/src/main&quot; includes=&quot;**/*.java&quot;&gt;
401 &lt;different targetdir=&quot;${ant.1.4.1}/src/main&quot;
402 ignoreFileTimes="true"/&gt;
403&lt;/fileset&gt;
404</pre></blockquote>
405
406 <p>Compares all the Java source files between the 1.4.1 and the 1.5 release
407 and selects those who are different, disregarding file times.
408 </p>
409
410 <a name="filenameselect"></a>
411 <h4>Filename Selector</h4>
412
413 <p>The <code>&lt;filename&gt;</code> tag acts like the
414 <code>&lt;include&gt;</code> and <code>&lt;exclude&gt;</code>
415 tags within a fileset. By using a selector instead, however,
416 one can combine it with all the other selectors using whatever
417 <a href="#selectcontainers">selector container</a> is desired.
418 </p>
419
420 <p>The <code>&lt;filename&gt;</code> selector is
421 case-sensitive.</p>
422
423 <table border="1" cellpadding="2" cellspacing="0">
424 <tr>
425 <td valign="top"><b>Attribute</b></td>
426 <td valign="top"><b>Description</b></td>
427 <td align="center" valign="top"><b>Required</b></td>
428 </tr>
429 <tr>
430 <td valign="top">name</td>
431 <td valign="top">The name of files to select. The name parameter
432 can contain the standard Ant wildcard characters.
433 </td>
434 <td valign="top" align="center">Yes</td>
435 </tr>
436 <tr>
437 <td valign="top">casesensitive</td>
438 <td valign="top">Whether to pay attention to case when looking
439 at file names. Default is "true".
440 </td>
441 <td valign="top" align="center">No</td>
442 </tr>
443 <tr>
444 <td valign="top">negate</td>
445 <td valign="top">Whether to reverse the effects of this filename
446 selection, therefore emulating an exclude rather than include
447 tag. Default is "false".
448 </td>
449 <td valign="top" align="center">No</td>
450 </tr>
451 </table>
452
453 <p>Here is an example of how to use the Filename Selector:</p>
454
455 <blockquote><pre>
456&lt;fileset dir=&quot;${doc.path}&quot; includes=&quot;**/*&quot;&gt;
457 &lt;filename name=&quot;**/*.css&quot;/&gt;
458&lt;/fileset&gt;
459</pre></blockquote>
460
461 <p>Selects all the cascading style sheet files.</p>
462
463
464 <a name="presentselect"></a>
465 <h4>Present Selector</h4>
466
467 <p>The <code>&lt;present&gt;</code> tag selects files
468 that have an equivalent file in another directory tree.</p>
469
470 <p>The <code>&lt;present&gt;</code> tag supports the use of a
471 contained <a href="mapper.html"><code>&lt;mapper&gt;</code></a> element
472 to define the location of the file to be tested against. If no
473 <code>&lt;mapper&gt;</code> element is specified, the
474 <code>identity</code> type mapper is used.</p>
475
476 <p>The <code>&lt;present&gt;</code> selector is case-sensitive.</p>
477
478 <table border="1" cellpadding="2" cellspacing="0">
479 <tr>
480 <td valign="top"><b>Attribute</b></td>
481 <td valign="top"><b>Description</b></td>
482 <td align="center" valign="top"><b>Required</b></td>
483 </tr>
484 <tr>
485 <td valign="top">targetdir</td>
486 <td valign="top">The base directory to look for the files to compare
487 against. The precise location depends on a combination of this
488 attribute and the <code>&lt;mapper&gt;</code> element, if any.
489 </td>
490 <td valign="top" align="center">Yes</td>
491 </tr>
492 <tr>
493 <td valign="top">present</td>
494 <td valign="top">Whether we are requiring that a file is present in
495 the src directory tree only, or in both the src and the target
496 directory tree. Valid values are:
497 <ul>
498 <li>srconly - select files only if they are in the src
499 directory tree but not in the target directory tree
500 <li>both - select files only if they are present both in the
501 src and target directory trees
502 </ul>
503 Default is both. Setting this attribute to &quot;srconly&quot;
504 is equivalent to wrapping the selector in the <code>&lt;not&gt;</code>
505 selector container.
506 </td>
507 <td valign="top" align="center">No</td>
508 </tr>
509 </table>
510
511 <p>Here is an example of how to use the Present Selector:</p>
512
513 <blockquote><pre>
514&lt;fileset dir=&quot;${ant.1.5}/src/main&quot; includes=&quot;**/*.java&quot;&gt;
515 &lt;present present=&quot;srconly&quot; targetdir=&quot;${ant.1.4.1}/src/main&quot;/&gt;
516&lt;/fileset&gt;
517</pre></blockquote>
518
519 <p>Selects all the Java source files which are new in the
520 1.5 release.
521 </p>
522
523 <a name="regexpselect"></a>
524 <h4>Regular Expression Selector</h4>
525
526 <p>The <code>&lt;containsregexp&gt;</code> tag in a FileSet limits
527 the files defined by that fileset to only those which contain a
528 match to the regular expression specified by the <code>expression</code> attribute.
529 </p>
530 <p>The <code>&lt;containsregexp&gt;</code> selector can be used as a
531 ResourceSelector (see the
532 <a href="resources.html#restrict">&lt;restrict&gt;</a>
533 ResourceCollection).</p>
534
535 <table border="1" cellpadding="2" cellspacing="0">
536 <tr>
537 <td valign="top"><b>Attribute</b></td>
538 <td valign="top"><b>Description</b></td>
539 <td align="center" valign="top"><b>Required</b></td>
540 </tr>
541 <tr>
542 <td valign="top">expression</td>
543 <td valign="top">Specifies the regular expression that must
544 match true in every file</td>
545 <td valign="top" align="center">Yes</td>
546 </tr>
547 </table>
548
549 <p>Here is an example of how to use the regular expression Selector:</p>
550
551 <blockquote><pre>
552&lt;fileset dir=&quot;${doc.path}&quot; includes=&quot;*.txt&quot;&gt;
553 &lt;containsregexp expression=&quot;[4-6]\.[0-9]&quot;/&gt;
554&lt;/fileset&gt;
555</pre></blockquote>
556
557 <p>Selects all the text files that match the regular expression
558 (have a 4,5 or 6 followed by a period and a number from 0 to 9).
559
560
561 <a name="sizeselect"></a>
562 <h4>Size Selector</h4>
563
564 <p>The <code>&lt;size&gt;</code> tag in a FileSet will put
565 a limit on the files specified by the include tag, so that tags
566 which do not meet the size limits specified by the selector will not
567 end up being selected.</p>
568
569 <table border="1" cellpadding="2" cellspacing="0">
570 <tr>
571 <td valign="top"><b>Attribute</b></td>
572 <td valign="top"><b>Description</b></td>
573 <td align="center" valign="top"><b>Required</b></td>
574 </tr>
575 <tr>
576 <td valign="top">value</td>
577 <td valign="top">The size of the file which should be tested for.
578 </td>
579 <td valign="top" align="center">Yes</td>
580 </tr>
581 <tr>
582 <td valign="top">units</td>
583 <td valign="top">The units that the <code>value</code> attribute
584 is expressed in. When using the standard single letter SI
585 designations, such as &quot;k&quot;,&quot;M&quot;, or
586 &quot;G&quot;, multiples of 1000 are used. If you want to use
587 power of 2 units, use the IEC standard: &quot;Ki&quot; for 1024,
588 &quot;Mi&quot; for 1048576, and so on. The default is no units,
589 which means the <code>value</code> attribute expresses the exact
590 number of bytes.
591 </td>
592 <td valign="top" align="center">No</td>
593 </tr>
594 <tr>
595 <td valign="top">when</td>
596 <td valign="top">Indicates how to interpret the size, whether
597 the files to be selected should be larger, smaller, or equal to
598 that value. Acceptable values for this attribute are:
599 <ul>
600 <li>less - select files less than the indicated size
601 <li>more - select files greater than the indicated size
602 <li>equal - select files this exact size
603 </ul>
604 The default is equal.
605 <td valign="top" align="center">No</td>
606 </tr>
607 </table>
608
609 <p>Here is an example of how to use the Size Selector:</p>
610
611 <blockquote><pre>
612&lt;fileset dir=&quot;${jar.path}&quot;&gt;
613 &lt;patternset&gt;
614 &lt;include name=&quot;**/*.jar&quot;/&gt;
615 &lt;/patternset&gt;
616 &lt;size value=&quot;4&quot; units=&quot;Ki&quot; when=&quot;more&quot;/&gt;
617&lt;/fileset&gt;
618</pre></blockquote>
619
620 <p>Selects all JAR files that are larger than 4096 bytes.</p>
621
622 <a name="typeselect"></a>
623 <h4>Type Selector</h4>
624
625 <p>The <code>&lt;type&gt;</code> tag selects files of a certain type:
626 directory or regular.</p>
627
628 <table border="1" cellpadding="2" cellspacing="0">
629 <tr>
630 <td valign="top"><b>Attribute</b></td>
631 <td valign="top"><b>Description</b></td>
632 <td align="center" valign="top"><b>Required</b></td>
633 </tr>
634 <tr>
635 <td valign="top">type</td>
636 <td valign="top">The type of file which should be tested for.
637 Acceptable values are:
638 <ul>
639 <li>file - regular files</li>
640 <li>dir - directories</li>
641 </ul>
642 </td>
643 <td valign="top" align="center">Yes</td>
644 </tr>
645 </table>
646
647 <p>Here is an example of how to use the Type Selector to select only
648 directories in <code>${src}</code></p>
649
650 <blockquote><pre>
651&lt;fileset dir=&quot;${src}&quot;&gt;
652 &lt;type type="dir"/&gt;
653&lt;/fileset&gt;
654</pre></blockquote>
655
656 <p>The Type Selector is often used in conjunction with other selectors.
657 For example, to select files that also exist in a <code>template</code>
658 directory, but avoid selecting empty directories, use:
659
660<blockquote><pre>
661&lt;fileset dir="${src}"&gt;
662 &lt;and&gt;
663 &lt;present targetdir="template"/&gt;
664 &lt;type type="file"/&gt;
665 &lt;/and&gt;
666&lt;/fileset&gt;
667</pre></blockquote>
668
669
670 <a name="modified"></a>
671 <h4>Modified Selector</h4>
672 <p>The <code>&lt;modified&gt;</code> selector computes a value for a file, compares that
673 to the value stored in a cache and select the file, if these two values
674 differ.</p>
675 <p>Because this selector is highly configurable the order in which the selection is done
676 is: <ol>
677 <li> get the absolute path for the file </li>
678 <li> get the cached value from the configured cache (absolute path as key) </li>
679 <li> get the new value from the configured algorithm </li>
680 <li> compare these two values with the configured comparator </li>
681 <li> update the cache if needed and requested </li>
682 <li> do the selection according to the comparison result </li>
683 </ol>
684 The comparison, computing of the hashvalue and the store is done by implementation
685 of special interfaces. Therefore they may provide additional parameters.</p>
686
687 <p>The <code>&lt;modified&gt;</code> selector can be used as a
688 ResourceSelector (see the
689 <a href="resources.html#restrict">&lt;restrict&gt;</a>
690 ResourceCollection).
691 In that case it maps simple file resources to files and does its job. If the
692 resource is from another type, the <code>&lt;modified&gt;</code> selector tries
693 to (<b>attention!</b>) copy the content into a local file for computing the
694 hashvalue.</p>
695
696 <table border="1" cellpadding="2" cellspacing="0">
697 <tr>
698 <td valign="top"><b>Attribute</b></td>
699 <td valign="top"><b>Description</b></td>
700 <td align="center" valign="top"><b>Required</b></td>
701 </tr>
702 <tr>
703 <td valign="top"> algorithm </td>
704 <td valign="top"> The type of algorithm should be used.
705 Acceptable values are (further information see later):
706 <ul>
707 <li> hashvalue - HashvalueAlgorithm </li>
708 <li> digest - DigestAlgorithm </li>
709 <li> checksum - ChecksumAlgorithm </li>
710 </ul>
711 </td>
712 <td valign="top" align="center"> No, defaults to <i>digest</i> </td>
713 </tr>
714 <tr>
715 <td valign="top"> cache </td>
716 <td valign="top"> The type of cache should be used.
717 Acceptable values are (further information see later):
718 <ul>
719 <li> propertyfile - PropertyfileCache </li>
720 </ul>
721 </td>
722 <td valign="top" align="center"> No, defaults to <i>propertyfile</i> </td>
723 </tr>
724 <tr>
725 <td valign="top"> comparator </td>
726 <td valign="top"> The type of comparator should be used.
727 Acceptable values are (further information see later):
728 <ul>
729 <li> equal - EqualComparator </li>
730 <li> rule - java.text.RuleBasedCollator
731 <!-- NOTE -->
732 <i>(see <a href="#ModSelNote">note</a> for restrictions)</i>
733 </li>
734 </ul>
735 </td>
736 <td valign="top" align="center"> No, defaults to <i>equal</i> </td>
737 </tr>
738 <tr>
739 <td valign="top"> algorithmclass </td>
740 <td valign="top"> Classname of custom algorithm implementation. Lower
741 priority than <i>algorithm</i>. </td>
742 <td valign="top" align="center"> No </td>
743 </tr>
744 <tr>
745 <td valign="top"> cacheclass </td>
746 <td valign="top"> Classname of custom cache implementation. Lower
747 priority than <i>cache</i>. </td>
748 <td valign="top" align="center"> No </td>
749 </tr>
750 <tr>
751 <td valign="top"> comparatorclass </td>
752 <td valign="top"> Classname of custom comparator implementation. Lower
753 priority than <i>comparator</i>. </td>
754 <td valign="top" align="center"> No </td>
755 </tr>
756 <tr>
757 <td valign="top"> update </td>
758 <td valign="top"> Should the cache be updated when values differ? (boolean) </td>
759 <td valign="top" align="center"> No, defaults to <i>true</i> </td>
760 </tr>
761 <tr>
762 <td valign="top"> seldirs </td>
763 <td valign="top"> Should directories be selected? (boolean) </td>
764 <td valign="top" align="center"> No, defaults to <i>true</i> </td>
765 </tr>
766 <tr>
767 <td valign="top"> selres </td>
768 <td valign="top"> Should Resources whithout an InputStream, and
769 therefore without checking, be selected? (boolean) </td>
770 <td valign="top" align="center"> No, defaults to <i>true</i>. Only relevant
771 when used as ResourceSelector. </td>
772 </tr>
773 <tr>
774 <td valign="top"> delayupdate </td>
775 <td valign="top"> If set to <i>true</i>, the storage of the cache will be delayed until the
776 next finished BuildEvent; task finished, target finished or build finished,
777 whichever comes first. This is provided for increased performance. If set
778 to <i>false</i>, the storage of the cache will happen with each change. This
779 attribute depends upon the <i>update</i> attribute. (boolean)</td>
780 <td valign="top" align="center"> No, defaults to <i>true</i> </td>
781 </tr>
782 </table>
783
784 <p>These attributes can be set with nested <code>&lt;param/&gt;</code> tags. With <code>&lt;param/&gt;</code>
785 tags you can set other values too - as long as they are named according to
786 the following rules: <ul>
787 <li> <b> algorithm </b>: same as attribute algorithm </li>
788 <li> <b> cache </b>: same as attribute cache </li>
789 <li> <b> comparator </b>: same as attribute comparator </li>
790 <li> <b> algorithmclass </b>: same as attribute algorithmclass </li>
791 <li> <b> cacheclass </b>: same as attribute cacheclass </li>
792 <li> <b> comparatorclass </b>: same as attribute comparatorclass </li>
793 <li> <b> update </b>: same as attribute update </li>
794 <li> <b> seldirs </b>: same as attribute seldirs </li>
795 <li> <b> algorithm.* </b>: Value is transfered to the algorithm via its
796 <i>set</i>XX-methods </li>
797 <li> <b> cache.* </b>: Value is transfered to the cache via its
798 <i>set</i>XX-methods </li>
799 <li> <b> comparator.* </b>: Value is transfered to the comparator via its
800 <i>set</i>XX-methods </li>
801 </ul></p>
802
803 <table border="1" cellpadding="2" cellspacing="0">
804 <tr><td colspan="2"><font size="+1"><b> Algorithm options</b></font></td></tr>
805 <tr>
806 <td valign="top"><b>Name</b></td>
807 <td valign="top"><b>Description</b></td>
808 </tr>
809 <tr>
810 <td valign="top"> hashvalue </td>
811 <td valign="top"> Reads the content of a file into a java.lang.String
812 and use thats hashValue(). No additional configuration required.
813 </td>
814 </tr>
815 <tr>
816 <td valign="top"> digest </td>
817 <td valign="top"> Uses java.security.MessageDigest. This Algorithm supports
818 the following attributes:
819 <ul>
820 <li><i>algorithm.algorithm</i> (optional): Name of the Digest algorithm
821 (e.g. 'MD5' or 'SHA', default = <i>MD5</i>) </li>
822 <li><i>algorithm.provider</i> (optional): Name of the Digest provider
823 (default = <i>null</i>) </li>
824 </ul>
825 </td>
826 </tr>
827 <tr>
828 <td valign="top"> checksum </td>
829 <td valign="top"> Uses java.util.zip.Checksum. This Algorithm supports
830 the following attributes:
831 <ul>
832 <li><i>algorithm.algorithm</i> (optional): Name of the algorithm
833 (e.g. 'CRC' or 'ADLER', default = <i>CRC</i>) </li>
834 </ul>
835 </td>
836 </tr>
837 <tr><td colspan="2"><font size="+1"><b> Cache options </b></font></td></tr>
838 <tr>
839 <td valign="top"> propertyfile </td>
840 <td valign="top"> Use the java.util.Properties class and its possibility
841 to load and store to file.
842 This Cache implementation supports the following attributes:
843 <ul>
844 <li><i>cache.cachefile</i> (optional): Name of the properties-file
845 (default = <i>cache.properties</i>) </li>
846 </ul>
847 </td>
848 </tr>
849 <tr><td colspan="2"><font size="+1"><b> Comparator options</b></font></td></tr>
850 <tr>
851 <td valign="top"> equal </td>
852 <td valign="top"> Very simple object comparison. </td>
853 </tr>
854 <tr>
855 <td valign="top"> rule </td>
856 <td valign="top"> Uses <i>java.text.RuleBasedCollator</i> for Object
857 comparison.
858 <!-- NOTE -->
859 <i>(see <a href="#ModSelNote">note</a> for restrictions)</i>
860 </td>
861 </tr>
862 </table>
863
864 <p>The <code>&lt;modified&gt;</code> selector supports a nested
865 <code>&lt;classpath&gt;</code> element that represents a <a href="../using.html#path">
866 PATH like structure</a> for finding custom interface implementations. </p>
867
868 <p>Here are some examples of how to use the Modified Selector:</p>
869
870 <blockquote><pre>
871 &lt;copy todir="dest"&gt;
872 &lt;fileset dir="src"&gt;
873 &lt;modified/&gt;
874 &lt;/fileset&gt;
875 &lt;/copy&gt;
876 </pre></blockquote>
877 <p>This will copy all files from <i>src</i> to <i>dest</i> which content has changed.
878 Using an updating PropertyfileCache with cache.properties and
879 MD5-DigestAlgorithm.</p>
880
881 <blockquote><pre>
882 &lt;copy todir="dest"&gt;
883 &lt;fileset dir="src"&gt;
884 &lt;modified update="true"
885 seldirs="true"
886 cache="propertyfile"
887 algorithm="digest"
888 comparator="equal"&gt;
889 &lt;param name="cache.cachefile" value="cache.properties"/&gt;
890 &lt;param name="algorithm.algorithm" value="MD5"/&gt;
891 &lt;/modified&gt;
892 &lt;/fileset&gt;
893 &lt;/copy&gt;
894 </pre></blockquote>
895 <p>This is the same example rewritten as CoreSelector with setting the all the values
896 (same as defaults are).</p>
897
898 <blockquote><pre>
899 &lt;copy todir="dest"&gt;
900 &lt;fileset dir="src"&gt;
901 &lt;custom class="org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector"&gt;
902 &lt;param name="update" value="true"/&gt;
903 &lt;param name="seldirs" value="true"/&gt;
904 &lt;param name="cache" value="propertyfile"/&gt;
905 &lt;param name="algorithm" value="digest"/&gt;
906 &lt;param name="comparator" value="equal"/&gt;
907 &lt;param name="cache.cachefile" value="cache.properties"/&gt;
908 &lt;param name="algorithm.algorithm" value="MD5"/&gt;
909 &lt;/custom&gt;
910 &lt;/fileset&gt;
911 &lt;/copy&gt;
912 </pre></blockquote>
913 <p>And this is the same rewritten as CustomSelector.</p>
914
915 <blockquote><pre>
916 &lt;target name="generate-and-upload-site"&gt;
917 &lt;echo&gt; generate the site using forrest &lt;/echo&gt;
918 &lt;antcall target="site"/&gt;
919
920 &lt;echo&gt; upload the changed file &lt;/echo&gt;
921 &lt;ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.pwd}"&gt;
922 &lt;fileset dir="htdocs/manual"&gt;
923 &lt;modified/&gt;
924 &lt;/fileset&gt;
925 &lt;/ftp&gt;
926 &lt;/target&gt;
927 </pre></blockquote>
928 <p>A useful scenario for this selector inside a build environment
929 for homepage generation (e.g. with <a href="http://xml.apache.org/forrest/">
930 Apache Forrest</a>). Here all <b>changed</b> files are uploaded to the server. The
931 CacheSelector saves therefore much upload time.</p>
932
933 <blockquote><pre>
934 &lt;modified cacheclassname="com.mycompany.MyCache"&gt;
935 &lt;classpath&gt;
936 &lt;pathelement location="lib/mycompony-antutil.jar"/&gt;
937 &lt;/classpath&gt;
938 &lt;/modified&gt;
939 </pre></blockquote>
940 <p>Uses <tt>com.mycompany.MyCache</tt> from a jar outside of Ants own classpath
941 as cache implementation</p>
942
943 <a name="ModSelNote"></a>
944 <h4>Note on RuleBasedCollator</h4>
945 <p>The RuleBasedCollator needs a format for its work, but its needed while
946 instantiation. There is a problem in the initialization algorithm for this
947 case. Therefore you should not use this (or tell me the workaround :-).</p>
948
949 <a name="signedselector"></a>
950 <h4>Signed Selector</h4>
951
952 <p>
953 The <code>&lt;signedselector&gt;</code> tag selects signed files and optionaly
954 signed with a certain name.
955 </p>
956 <p>
957 This selector has been added in Apache Ant 1.7.
958 </p>
959 <table border="1" cellpadding="2" cellspacing="0">
960 <tr>
961 <td valign="top"><b>Attribute</b></td>
962 <td valign="top"><b>Description</b></td>
963 <td align="center" valign="top"><b>Required</b></td>
964 </tr>
965 <tr>
966 <td valign="top">name</td>
967 <td valign="top"> The signature name to check for.</td>
968 <td valign="top" align="center">no</td>
969 </tr>
970 </table>
971
972 <a name="scriptselector"></a>
973 <h4>Script Selector</h4>
974
975 <p>
976 The <code>&lt;scriptselector&gt;</code> element enables you
977 to write a complex selection algorithm in any
978 <a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a>
979 or
980 <a href="https://scripting.dev.java.net">JSR 223</a>
981 supported language.</p>
982 See the <a href="../OptionalTasks/script.html">Script</a> task for
983 an explanation of scripts and dependencies.
984 </p>
985 <p>
986 This selector was added in Apache Ant 1.7.
987 </p>
988 <table border="1" cellpadding="2" cellspacing="0">
989 <tr>
990 <td valign="top"><b>Attribute</b></td>
991 <td valign="top"><b>Description</b></td>
992 <td align="center" valign="top"><b>Required</b></td>
993 </tr>
994 <tr>
995 <td valign="top">language</td>
996 <td valign="top">language of the script.</td>
997 <td valign="top" align="center">yes</td>
998 </tr>
999 <tr>
1000 <td valign="top">manager</td>
1001 <td valign="top">
1002 The script engine manager to use.
1003 See the <a href="../OptionalTasks/script.html">script</a> task
1004 for using this attribute.
1005 </td>
1006 <td valign="top" align="center">No - default is "auto"</td>
1007 </tr>
1008 <tr>
1009 <td valign="top">src</td>
1010 <td valign="top">filename of the script</td>
1011 <td valign="top" align="center">no</td>
1012 </tr>
1013 <tr>
1014 <td valign="top">setbeans</td>
1015 <td valign="top">whether to have all properties, references and targets as
1016 global variables in the script.</td>
1017 <td valign="top" align="center">No, default is "true".</td>
1018 </tr>
1019 <tr>
1020 <td valign="top">classpath</td>
1021 <td valign="top">
1022 The classpath to pass into the script.
1023 </td>
1024 <td align="center" valign="top">No</td>
1025 </tr>
1026 <tr>
1027 <td valign="top">classpathref</td>
1028 <td valign="top">The classpath to use, given as a
1029 <a href="../using.html#references">reference</a> to a path defined elsewhere.
1030 <td align="center" valign="top">No</td>
1031 </tr>
1032 </table>
1033 <p>
1034 This selector can take a nested &lt;classpath&gt; element.
1035 See the <a href="../OptionalTasks/script.html">script</a> task
1036 on how to use this element.
1037 </p>
1038 <p>
1039 If no <code>src</code> attribute is supplied, the script must be nested
1040 inside the selector declaration.
1041 </p>
1042 <p>The embedded script is invoked for every test, with
1043 the bean <code>self</code>
1044 is bound to the selector. It has an attribute <code>selected</code>
1045 must can be set using <code>setSelected(boolean)</code> to select that
1046 file.
1047
1048 <p>
1049
1050 The following beans are configured for every script, alongside
1051 the classic set of project, properties, and targets.
1052
1053 <table border="1" cellpadding="2" cellspacing="0">
1054 <tr>
1055 <td valign="top"><b>Bean</b></td>
1056 <td valign="top"><b>Description</b></td>
1057 <td valign="top"><b>Type</b></td>
1058 </tr>
1059 <tr>
1060 <td valign="top">self</td>
1061 <td valign="top">selector instance</td>
1062 <td valign="top">org.apache.tools.ant.types.optional</td>
1063 </tr>
1064 <tr>
1065 <td valign="top">filename</td>
1066 <td valign="top">filename of the selection</td>
1067 <td valign="top" >String</td>
1068 </tr>
1069 <tr>
1070 <td valign="top">file</td>
1071 <td valign="top">file of the selection</td>
1072 <td valign="top" >java.io.File</td>
1073 </tr>
1074 <tr>
1075 <td valign="top">basedir</td>
1076 <td valign="top">Fileset base directory</td>
1077 <td valign="top" >java.io.File</td>
1078 </tr>
1079
1080 </table>
1081 <p>
1082 The <code>self</code> bean maps to the selector, which has the following
1083 attributes. Only the <code>selected</code> flag is writeable, the rest
1084 are read only via their getter methods.
1085
1086 <table border="1" cellpadding="2" cellspacing="0">
1087 <tr>
1088 <td valign="top"><b>Attribute</b></td>
1089 <td valign="top"><b>Description</b></td>
1090 <td align="center" valign="top"><b>Type</b></td>
1091 </tr>
1092 <tr>
1093 <td valign="top">selected</td>
1094 <td valign="top">writeable flag to select this file</td>
1095 <td valign="top" align="center">boolean</td>
1096 </tr>
1097 <tr>
1098 <td valign="top">filename</td>
1099 <td valign="top">filename of the selection</td>
1100 <td valign="top" >String</td>
1101 </tr>
1102 <tr>
1103 <td valign="top">file</td>
1104 <td valign="top">file of the selection</td>
1105 <td valign="top" >java.io.File</td>
1106 </tr>
1107 <tr>
1108 <td valign="top">basedir</td>
1109 <td valign="top">Fileset base directory</td>
1110 <td valign="top" >java.io.File</td>
1111 </tr>
1112 </table>
1113
1114 <p>
1115 Example
1116 </p>
1117<pre>
1118 &lt;scriptselector language=&quot;javascript&quot;&gt;
1119 self.setSelected(true);
1120 &lt;/scriptselector&gt;
1121</pre>
1122 <p>
1123 Selects every file.
1124 </p>
1125
1126<pre>
1127 &lt;scriptselector language=&quot;javascript&quot;&gt;
1128 self.setSelected((filename.length%2)==0);
1129 &lt;/scriptselector&gt;
1130</pre>
1131Select files whose filename length is even.
1132
1133 <a name="selectcontainers"></a>
1134 <h3>Selector Containers</h3>
1135
1136 <p>To create more complex selections, a variety of selectors that
1137 contain other selectors are available for your use. They combine the
1138 selections of their child selectors in various ways.</p>
1139
1140 <p>The selector containers are:</p>
1141
1142 <ul>
1143 <li><a href="#andselect"><code>&lt;and&gt;</code></a> - select a file only if all
1144 the contained selectors select it.
1145 <li><a href="#majorityselect"><code>&lt;majority&gt;</code></a> - select a file
1146 if a majority of its selectors select it.
1147 <li><a href="#noneselect"><code>&lt;none&gt;</code></a> - select a file only if
1148 none of the contained selectors select it.
1149 <li><a href="#notselect"><code>&lt;not&gt;</code></a> - can contain only one
1150 selector, and reverses what it selects and doesn't select.
1151 <li><a href="#orselect"><code>&lt;or&gt;</code></a> - selects a file if any one
1152 of the contained selectors selects it.
1153 <li><a href="#selectorselect"><code>&lt;selector&gt;</code></a> - contains only one
1154 selector and forwards all requests to it without alteration, provided
1155 that any <code>&quot;if&quot;</code> or
1156 <code>&quot;unless&quot;</code> conditions are met. This
1157 is the selector to use if you want to define a reference. It is
1158 usable as an element of <code>&lt;project&gt;</code>. It is also
1159 the one to use if you want selection of files to be dependent on
1160 Ant property settings.
1161 </ul>
1162
1163 <p>All selector containers can contain any other selector, including
1164 other containers, as an element. Using containers, the selector tags
1165 can be arbitrarily deep. Here is a complete list of allowable
1166 selector elements within a container:</P>
1167
1168 <ul>
1169 <li><code>&lt;and&gt;</code></li>
1170 <li><code>&lt;contains&gt;</code></li>
1171 <li><code>&lt;custom&gt;</code></li>
1172 <li><code>&lt;date&gt;</code></li>
1173 <li><code>&lt;depend&gt;</code></li>
1174 <li><code>&lt;depth&gt;</code></li>
1175 <li><code>&lt;filename&gt;</code></li>
1176 <li><code>&lt;majority&gt;</code></li>
1177 <li><code>&lt;none&gt;</code></li>
1178 <li><code>&lt;not&gt;</code></li>
1179 <li><code>&lt;or&gt;</code></li>
1180 <li><code>&lt;present&gt;</code></li>
1181 <li><code>&lt;selector&gt;</code></li>
1182 <li><code>&lt;size&gt;</code></li>
1183 </ul>
1184
1185 <a name="andselect"></a>
1186 <h4>And Selector</h4>
1187
1188 <p>The <code>&lt;and&gt;</code> tag selects files that are
1189 selected by all of the elements it contains. It returns as
1190 soon as it finds a selector that does not select the file,
1191 so it is not guaranteed to check every selector.
1192 </p>
1193
1194 <p>Here is an example of how to use the And Selector:</p>
1195
1196 <blockquote><pre>
1197&lt;fileset dir=&quot;${dist}&quot; includes=&quot;**/*.jar&quot;&gt;
1198 &lt;and&gt;
1199 &lt;size value=&quot;4&quot; units=&quot;Ki&quot; when=&quot;more&quot;/&gt;
1200 &lt;date datetime=&quot;01/01/2001 12:00 AM&quot; when=&quot;before&quot;/&gt;
1201 &lt;/and&gt;
1202&lt;/fileset&gt;
1203</pre></blockquote>
1204
1205 <p>Selects all the JAR file larger than 4096 bytes which haven't been update
1206 since the last millenium.
1207 </p>
1208
1209
1210 <a name="majorityselect"></a>
1211 <h4>Majority Selector</h4>
1212
1213 <p>The <code>&lt;majority&gt;</code> tag selects files provided
1214 that a majority of the contained elements also select it. Ties are
1215 dealt with as specified by the <code>allowtie</code> attribute.
1216 </p>
1217
1218 <table border="1" cellpadding="2" cellspacing="0">
1219 <tr>
1220 <td valign="top"><b>Attribute</b></td>
1221 <td valign="top"><b>Description</b></td>
1222 <td align="center" valign="top"><b>Required</b></td>
1223 </tr>
1224 <tr>
1225 <td valign="top">allowtie</td>
1226 <td valign="top">Whether files should be selected if there
1227 are an even number of selectors selecting them as are
1228 not selecting them. Default is true.
1229 </td>
1230 <td valign="top" align="center">No</td>
1231 </tr>
1232 </table>
1233
1234
1235 <p>Here is an example of how to use the Majority Selector:</p>
1236
1237 <blockquote><pre>
1238&lt;fileset dir=&quot;${docs}&quot; includes=&quot;**/*.html&quot;&gt;
1239 &lt;majority&gt;
1240 &lt;contains text=&quot;project&quot; casesensitive="false"/&gt;
1241 &lt;contains text=&quot;taskdef&quot; casesensitive="false"/&gt;
1242 &lt;contains text=&quot;IntrospectionHelper&quot; casesensitive="true"/&gt;
1243 &lt;/majority&gt;
1244&lt;/fileset&gt;
1245</pre></blockquote>
1246
1247 <p>Selects all the HTML files which contain at least two of the three
1248 phrases "project", "taskdef", and "IntrospectionHelper" (this last phrase must
1249 match case exactly).
1250 </p>
1251
1252
1253 <a name="noneselect"></a>
1254 <h4>None Selector</h4>
1255
1256 <p>The <code>&lt;none&gt;</code> tag selects files that are
1257 not selected by any of the elements it contains. It returns as
1258 soon as it finds a selector that selects the file,
1259 so it is not guaranteed to check every selector.
1260 </p>
1261
1262 <p>Here is an example of how to use the None Selector:</p>
1263
1264 <blockquote><pre>
1265&lt;fileset dir=&quot;${src}&quot; includes=&quot;**/*.java&quot;&gt;
1266 &lt;none&gt;
1267 &lt;present targetdir=&quot;${dest}&quot;/&gt;
1268 &lt;present targetdir=&quot;${dest}&quot;&gt;
1269 &lt;mapper type=&quot;glob&quot; from=&quot;*.java&quot; to=&quot;*.class&quot;/&gt;
1270 &lt;/present&gt;
1271 &lt;/none&gt;
1272&lt;/fileset&gt;
1273</pre></blockquote>
1274
1275 <p>Selects only Java files which do not have equivalent java or
1276 class files in the dest directory.
1277 </p>
1278
1279
1280 <a name="notselect"></a>
1281 <h4>Not Selector</h4>
1282
1283 <p>The <code>&lt;not&gt;</code> tag reverses the meaning of the
1284 single selector it contains.
1285 </p>
1286
1287 <p>Here is an example of how to use the Not Selector:</p>
1288
1289 <blockquote><pre>
1290&lt;fileset dir=&quot;${src}&quot; includes=&quot;**/*.java&quot;&gt;
1291 &lt;not&gt;
1292 &lt;contains text=&quot;test&quot;/&gt;
1293 &lt;/not&gt;
1294&lt;/fileset&gt;
1295</pre></blockquote>
1296
1297 <p>Selects all the files in the src directory that do not contain the
1298 string "test".
1299 </p>
1300
1301
1302 <a name="orselect"></a>
1303 <h4>Or Selector</h4>
1304
1305 <p>The <code>&lt;or&gt;</code> tag selects files that are
1306 selected by any one of the elements it contains. It returns as
1307 soon as it finds a selector that selects the file,
1308 so it is not guaranteed to check every selector.
1309 </p>
1310
1311 <p>Here is an example of how to use the Or Selector:</p>
1312
1313 <blockquote><pre>
1314&lt;fileset dir=&quot;${basedir}&quot;&gt;
1315 &lt;or&gt;
1316 &lt;depth max=&quot;0&quot;/&gt;
1317 &lt;filename name="*.png"/&gt;
1318 &lt;filename name="*.gif"/&gt;
1319 &lt;filename name="*.jpg"/&gt;
1320 &lt;/or&gt;
1321&lt;/fileset&gt;
1322</pre></blockquote>
1323
1324 <p>Selects all the files in the top directory along with all the
1325 image files below it.
1326 </p>
1327
1328
1329 <a name="selectorselect"></a>
1330 <h4>Selector Reference</h4>
1331
1332 <p>The <code>&lt;selector&gt;</code> tag is used to create selectors
1333 that can be reused through references. It is the only selector which can
1334 be used outside of
1335 any target, as an element of the <code>&lt;project&gt;</code> tag. It
1336 can contain only one other selector, but of course that selector can
1337 be a container.
1338 </p>
1339
1340 <p>The <code>&lt;selector&gt;</code> tag can also be used to select
1341 files conditionally based on whether an Ant property exists or not.
1342 This functionality is realized using the <code>&quot;if&quot;</code> and
1343 <code>&quot;unless&quot;</code> attributes in exactly the same way they
1344 are used on targets or on the <code>&lt;include&gt;</code> and
1345 <code>&lt;exclude&gt;</code> tags within a
1346 <code>&lt;patternset&gt;</code>.</p>
1347
1348 <table border="1" cellpadding="2" cellspacing="0">
1349 <tr>
1350 <td valign="top"><b>Attribute</b></td>
1351 <td valign="top"><b>Description</b></td>
1352 <td align="center" valign="top"><b>Required</b></td>
1353 </tr>
1354 <tr>
1355 <td valign="top">if</td>
1356 <td valign="top">Allow files to be selected only if the named
1357 property is set.
1358 </td>
1359 <td valign="top" align="center">No</td>
1360 </tr>
1361 <tr>
1362 <td valign="top">unless</td>
1363 <td valign="top">Allow files to be selected only if the named
1364 property is <b>not</b> set.
1365 </td>
1366 <td valign="top" align="center">No</td>
1367 </tr>
1368 </table>
1369
1370 <p>Here is an example of how to use the Selector Reference:</p>
1371
1372 <blockquote><pre>
1373&lt;project default=&quot;all&quot; basedir=&quot;./ant&quot;&gt;
1374
1375 &lt;selector id=&quot;completed&quot;&gt;
1376 &lt;none&gt;
1377 &lt;depend targetdir=&quot;build/classes&quot;&gt;
1378 &lt;mapper type=&quot;glob&quot; from=&quot;*.java&quot; to=&quot;*.class&quot;/&gt;
1379 &lt;/depend&gt;
1380 &lt;depend targetdir=&quot;docs/manual/api&quot;&gt;
1381 &lt;mapper type=&quot;glob&quot; from=&quot;*.java&quot; to=&quot;*.html&quot;/&gt;
1382 &lt;/depend&gt;
1383 &lt;/none&gt;
1384 &lt;/selector&gt;
1385
1386 &lt;target&gt;
1387 &lt;zip&gt;
1388 &lt;fileset dir=&quot;src/main&quot; includes=&quot;**/*.java&quot;&gt;
1389 &lt;selector refid=&quot;completed&quot;/&gt;
1390 &lt;/fileset&gt;
1391 &lt;/zip&gt;
1392 &lt;/target&gt;
1393
1394&lt;/project&gt;
1395</pre></blockquote>
1396
1397 <p>Zips up all the Java files which have an up-to-date equivalent
1398 class file and javadoc file associated with them.
1399 </p>
1400
1401 <p>And an example of selecting files conditionally, based on whether
1402 properties are set:</p>
1403
1404 <blockquote><pre>
1405&lt;fileset dir=&quot;${working.copy}&quot;&gt;
1406 &lt;or&gt;
1407 &lt;selector if=&quot;include.tests&quot;&gt;
1408 &lt;filename name=&quot;**/*Test.class&quot;&gt;
1409 &lt;/selector&gt;
1410 &lt;selector if=&quot;include.source&quot;&gt;
1411 &lt;and&gt;
1412 &lt;filename name=&quot;**/*.java&quot;&gt;
1413 &lt;not&gt;
1414 &lt;selector unless=&quot;include.tests&quot;&gt;
1415 &lt;filename name=&quot;**/*Test.java&quot;&gt;
1416 &lt;/selector&gt;
1417 &lt;/not&gt;
1418 &lt;/and&gt;
1419 &lt;/selector&gt;
1420 &lt;/or&gt;
1421&lt;/fileset&gt;
1422</pre></blockquote>
1423
1424 <p>A fileset that conditionally contains Java source files and Test
1425 source and class files.</p>
1426
1427 <a name="customselect"></a>
1428 <h3>Custom Selectors</h3>
1429
1430 <p>You can write your own selectors and use them within the selector
1431 containers by specifying them within the <code>&lt;custom&gt;</code> tag.</p>
1432
1433 <p>First, you have to write your selector class in Java. The only
1434 requirement it must meet in order to be a selector is that it implements
1435 the <code>org.apache.tools.ant.types.selectors.FileSelector</code>
1436 interface, which contains a single method. See
1437 <a href="selectors-program.html">Programming Selectors in Ant</a> for
1438 more information.</p>
1439
1440 <p>Once that is written, you include it in your build file by using
1441 the <code>&lt;custom&gt;</code> tag.
1442 </p>
1443
1444 <table border="1" cellpadding="2" cellspacing="0">
1445 <tr>
1446 <td valign="top"><b>Attribute</b></td>
1447 <td valign="top"><b>Description</b></td>
1448 <td align="center" valign="top"><b>Required</b></td>
1449 </tr>
1450 <tr>
1451 <td valign="top">classname</td>
1452 <td valign="top">The name of your class that implements
1453 <code>org.apache.tools.ant.types.selectors.FileSelector</code>.
1454 </td>
1455 <td valign="top" align="center">Yes</td>
1456 </tr>
1457 <tr>
1458 <td valign="top">classpath</td>
1459 <td valign="top">The classpath to use in order to load the
1460 custom selector class. If neither this classpath nor the
1461 classpathref are specified, the class will be
1462 loaded from the classpath that Ant uses.
1463 </td>
1464 <td valign="top" align="center">No</td>
1465 </tr>
1466 <tr>
1467 <td valign="top">classpathref</td>
1468 <td valign="top">A reference to a classpath previously
1469 defined. If neither this reference nor the
1470 classpath above are specified, the class will be
1471 loaded from the classpath that Ant uses.
1472 </td>
1473 <td valign="top" align="center">No</td>
1474 </tr>
1475 </table>
1476
1477 <p>Here is how you use <code>&lt;custom&gt;</code> to
1478 use your class as a selector:
1479 </p>
1480
1481 <blockquote><pre>
1482&lt;fileset dir=&quot;${mydir}&quot; includes=&quot;**/*&quot;&gt;
1483 &lt;custom classname=&quot;com.mydomain.MySelector&quot;&gt;
1484 &lt;param name=&quot;myattribute&quot; value=&quot;myvalue&quot;/&gt;
1485 &lt;/custom&gt;
1486&lt;/fileset&gt;
1487</pre></blockquote>
1488
1489 <p>A number of core selectors can also be used as custom selectors
1490 by specifying their attributes using <code>&lt;param&gt;</code> elements. These
1491 are</p>
1492
1493 <ul>
1494 <li><a href="#containsselect">Contains Selector</a> with
1495 classname <code>org.apache.tools.ant.types.selectors.ContainsSelector</code>
1496 <li><a href="#dateselect">Date Selector</a> with
1497 classname <code>org.apache.tools.ant.types.selectors.DateSelector</code>
1498 <li><a href="#depthselect">Depth Selector</a> with
1499 classname <code>org.apache.tools.ant.types.selectors.DepthSelector</code>
1500 <li><a href="#filenameselect">Filename Selector</a> with
1501 classname <code>org.apache.tools.ant.types.selectors.FilenameSelector</code>
1502 <li><a href="#sizeselect">Size Selector</a> with
1503 classname <code>org.apache.tools.ant.types.selectors.SizeSelector</code>
1504 </ul>
1505
1506 <p>Here is the example from the Depth Selector section rewritten
1507 to use the selector through <code>&lt;custom&gt;</code>.</p>
1508
1509 <blockquote><pre>
1510&lt;fileset dir=&quot;${doc.path}&quot; includes=&quot;**/*&quot;&gt;
1511 &lt;custom classname=&quot;org.apache.tools.ant.types.selectors.DepthSelector&quot;&gt;
1512 &lt;param name=&quot;max&quot; value=&quot;1&quot;/&gt;
1513 &lt;/custom&gt;
1514&lt;/fileset&gt;
1515</pre></blockquote>
1516
1517 <p>Selects all files in the base directory and one directory below
1518 that.</p>
1519
1520 <p>For more details concerning writing your own selectors, consult
1521 <a href="selectors-program.html">Programming Selectors in Ant</a>.</p>
1522
1523
1524
1525 </body>
1526
1527</html>
Note: See TracBrowser for help on using the repository browser.