ANT File Set
Ant File Set :
- The Fileset refer as a collection of files.
- The Fileset is generally used as a filter to include and exclude files that match a particular pattern.
Sample Example:
<fileset dir="${src}" casesensitive="yes"> <include name="**/*.java"/> <exclude name="**/*Order*"/> </fileset>
Explanation of Build Script :
- The src attribute written in fileset element points to the source folder of the project.
- The fileset selects all java files in the source folder but all the java files containing the word ‘Order’ will be excluded
- The filter applied to the fileset is case sensitive so file with the name Processorder.java will not be excluded from the fileset
Examples of Ant FileSet :
Example 1 :
<fileset dir="${src}" casesensitive="yes"> <include name="**/*.java"/> <exclude name="**/*Test*"/> </fileset>
All the files from ‘src’ folder having extension ‘.java’ will be included in the file set excluding the files having word ‘Test’ in their name.
Different FileSet Attributes :
Attribute | Description | Required |
---|---|---|
dir | the root of the directory tree of this FileSet | |
file | shortcut for specifying a single-file fileset | |
defaultexcludes | indicates whether default excludes should be used or not (yes | no); default excludes are used when omitted. | No |
includes | comma- or space-separated list of patterns of files that must be included; all files are included when omitted. | No |
includesfile | the name of a file; each line of this file is taken to be an include pattern. | No |
excludes | comma- or space-separated list of patterns of files that must be excluded; no files (except default excludes) are excluded when omitted. | No |
excludesfile | the name of a file; each line of this file is taken to be an exclude pattern. | No |
casesensitive | Must the include and exclude patterns be treated in a case sensitive way? Defaults to true. | No |
followsymlinks | Shall symbolic links be followed? Defaults to true. See the note below. | No |
erroronmissingdir | Specify what happens if the base directory does not exist. If true a build error will happen, if false, the fileset will be ignored/empty. Defaults to true. Since Apache Ant 1.7.1 (default is true for backward compatibility reasons.) | No |