PatternSets andSelectors.PatternSets can be specified as nested<patternset>
elements. In addition, FileSet holdsan implicit PatternSet and supports the nested<include>
, <includesfile>
,<exclude>
and <excludesfile>
elements of PatternSet directly, as well as PatternSet'sattributes.
Selectors are available as nested elements within the FileSet.If any of the selectors within the FileSet do not select the file, thefile is not considered part of the FileSet. This makes a FileSetequivalent to an <and>
selector container.
Attribute | Description | Required |
dir | the root of the directory tree of this FileSet. | Either dir or file must be specified |
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 |
Note: All files/directories for whichthe canonical path is different from its path are considered symboliclinks. On Unix systems this usually means the file really is asymbolic link but it may lead to false results on otherplatforms.
Examples
<fileset dir="${server.src}" casesensitive="yes"> <include name="**/*.java"/> <exclude name="**/*Test*"/></fileset>
Groups all files in directory ${server.src}
that are Javasource files and don't have the text Test
in theirname.
<fileset dir="${server.src}" casesensitive="yes"> <patternset id="non.test.sources"> <include name="**/*.java"/> <exclude name="**/*Test*"/> </patternset></fileset>
Groups the same files as the above example, but also establishesa PatternSet that can be referenced in other<fileset>
elements, rooted at a different directory.
<fileset dir="${client.src}" > <patternset refid="non.test.sources"/></fileset>
Groups all files in directory ${client.src}
, using thesame patterns as the above example.
<fileset dir="${server.src}" casesensitive="yes"> <filename name="**/*.java"/> <filename name="**/*Test*" negate="true"/></fileset>
Groups the same files as the top example, but using the<filename>
selector.
<fileset dir="${server.src}" casesensitive="yes"> <filename name="**/*.java"/> <not> <filename name="**/*Test*"/> </not></fileset>
Groups the same files as the previous example using a combination of the<filename>
selector and the <not>
selector container.
<fileset dir="src" includes="main/" />
Selects all files in src/main (e.g. src/main/Foo.java or src/main/application/Bar.java).