Page 34      All Pages  All Books
Apache Ant User Manual Guide – Version 1.6.0                                                                                      12/29/2003 9:39 AM
Note: If a token with the format @token@ is found in a file, but no filter is associated with that token, no changes take place; therefore, no escaping method is available - but as long as you choose appropriate names for your tokens, this should not cause problems.
Warning: If you copy binary files with filtering turned on, you can corrupt the files. This feature should be used with text files only.
6.1.8 Path-like Structures
You can specify PATH- and CLASSPATH-type references using both ":" and ";" as separator characters. Ant will convert the separator to the correct character of the current operating system.
Wherever path-like values need to be specified, a nested element can be used. This takes the general form of:
<classpath>
<pathelement path="${classpath}"/>
<pathelement location="lib/helper.jar"/> </classpath>
The location attribute specifies a single file or directory relative to the project's base directory (or an absolute filename), while the path attribute accepts colon- or semicolon-separated lists of locations. The path attribute is intended to be used with predefined paths - in any other case, multiple elements with location attributes should be preferred. As a shortcut, the <classpath> tag supports path and location attributes of its own, so:
<classpath>
<pathelement path="${classpath}"/> </classpath>
can be abbreviated to:
<classpath path="${classpath}"/>
In addition, DirSets, FileSets, and FileLists can be specified via nested <dirset>, <fileset>, and <filelist> elements, respectively. Note: The order in which the files building up a FileSet are added to the path-like structure is not defined.
<classpath>
<pathelement path="${classpath}"/> <fileset dir="lib">
<include name="**/*.jar"/> </fileset>
<pathelement location="classes"/> <dirset dir="${build.dir}">
<include name="apps/**/classes"/>
<exclude name="apps/**/*Test*"/> </dirset>
<filelist refid="third-party_jars"/> </classpath>
This builds a path that holds the value of ${classpath}, followed by all jar files in the lib directory, the classes directory, all directories named classes under the apps subdirectory of ${build.dir}, except those that have the text Test in their name, and the files specified in the referenced FileList.
If you want to use the same path-like structure for several tasks, you can define them with a <path> element at the same level as targets, and reference them via their id attribute - see References for an example.
27 of 130

Page 34      All Pages  All Books