Original: http://www.cnblogs.com/itech/archive/2011/11/01/2231206.html
First, <path/> and <classpath/>
You can use ":" and ";" As a delimiter, specify a reference like path and classpath. Ant will convert the delimiter to the delimiter used by the current system.
You can use nested elements when you need to specify a value that resembles a path. The general form is
<classpath>
<pathelement path= "{classpath}"/>
<pathelement location= "Lib/helper.jar"/>
</classpath>
The Location property specifies a file and directory relative to the project base directory, and the Path property accepts a comma-or semicolon-delimited list of locations. The Path property is generally used as a predefined path, and in other cases, multiple location properties should be used.
For brevity, the CLASSPATH tag supports its own path and location properties. So:
<classpath>
<pathelement path= "{classpath}"/>
</classpath>
Can be written by Jane:
<classpath path= "{classpath}"/>
You can also specify the path through the <fileset> element. The order in which multiple files composing a fileset join path-like structure is undefined.
<classpath>
<pathelement path= "{classpath}"/>
<fileset dir= "Lib" >
<include name= "**/*.jar"/>
</fileset>
<pathelement location= "Classes"/>
</classpath>
The above example constructs a path value including: {Classpath}, followed by all jar files in the Lib directory, followed by the classes directory.
If you want to use the same path-like structure in multiple tasks, you can define them with the <path> element (same as target sibling), and then refer to them by the id attribute.
Path-like structure may include a reference to another Path-like Structurede (via nesting <path> elements):
<path id= "Base.path" >
<pathelement path= "{classpath}"/>
<fileset dir= "Lib" >
<include name= "**/*.jar"/>
</fileset>
<pathelement location= "Classes"/>
</path>
<path id= "Tests.path" >
<path refid= "Base.path"/>
<pathelement location= "Testclasses"/>
</path>
The concise wording of <classpath> mentioned above is also effective for <path>, such as:
<path id= "Tests.path" >
<path refid= "Base.path"/>
<pathelement location= "Testclasses"/>
</path>
Can be written as:
<path id= "Base.path" path= "{classpath}"/>
Second, Fileset
1) Fileset is a set of files that can be found under the Base directory tree and match the specified patternsets and selectors. The structure of the fileset is similar to the following:
<fileset dir= "${server.src}" >
<patternset/>
<Selector/>
</fileset>
2) Patternset is generally used as a child element of Fileset to help filter files. Can contain the following child elements:include,exclude,includes,excludes,includesfile,excludesfile.
Fileset implicitly contains a patternset element, so you can directly include elements in the Patterset in Fileset, such as <include>, <includesfile>, <exclude > and <excludesfile>.
The following patternset contains the Java file under the STD subdirectory, and if the professional definition contains the Java file under Prof, but does not contain the file with the test in the name.
<patternset id= "Sources" >
<include name= "Std/**/*.java"/>
<include name= "Prof/**/*.java" if= "professional"/>
<exclude name= "**/*test*"/>
</patternset>
3) selector is generally used as a child element of Fileset to help filter files.
The Common Core selector are:
<contains>-Used to select the file containing the specified string
<date>-Used to select files that were modified before or after a specific time
<depend>-Select files that has been modified more recently than equivalent files elsewhere
<depth>-A file to select the specified directory depth
<different>-Select files that is different from those elsewhere
<filename>-Files that select file names to match a specific pattern. Equivalent to the patternset of include and exclude.
<present>-Used to select a file that exists or does not exist at a location
<containsregexp>-To select a file that matches the specified regular expression
<size>-Used to select files larger or smaller than the specified size
<type>-Select files that is either regular files or directories.
<modified>-Select files if the return value of the configured algorithm is different from this stored in a CAC He.
<signedselector>-Select files if they is signed, and optionally if they has a signature of a certain name.
<scriptselector>-Use a BSF or JSR 223 scripting language to create your own selector
<readable>-Select a file with the readable attribute
<writable>-Select a file with the writable attribute
For example, select all HTML files that contain script
<fileset dir= "${doc.path}" includes= "**/*.html" >
<contains text= "Script" casesensitive= "no"/>
</fileset>
For example, select all jar files that were modified before january1,2001
<fileset dir= "${jar.path}" includes= "**/*.jar" >
<date datetime= "01/01/2001" when= "before"/>
</fileset>
For example, select all TXT files that meet regular expressions
<fileset dir= "${doc.path}" includes= "*.txt" >
<containsregexp expression= "[4-6]\. [0-9] "/>
</fileset>
The following selector and Patternset are equivalent:
<fileset dir= "${server.src}" casesensitive= "yes" >
<filename name= "**/*.java"/>
<not>
<filename name= "**/*test*"/>
</not>
</fileset>
Equivalent to
<fileset dir= "${server.src}" casesensitive= "yes" >
<filename name= "**/*.java"/>
<filename name= "**/*test*" negate= "true"/>
</fileset>
Equivalent to
<fileset dir= "${server.src}" casesensitive= "yes" >
<include name= "**/*.java"/>
<exclude name= "**/*test*"/>
</fileset>
Selector containers can contain other selector, commonly used selector containers are:
<and>
<contains>
<custom>
<date>
<depend>
<depth>
<filename>
<majority>
<none>
<not>
<or>
<present>
<selector>
<size>
For example, choose a jar file that is larger than 4096bytes and not updated from the previous millenium
<fileset dir= "${dist}" includes= "**/*.jar" >
<and>
<size value= "4" units= "Ki" when= "more"/>
<date datetime= "01/01/2001" when= "before"/>
</and>
</fileset>
Go Ant Advanced-path and Fileset