## FileSet

A FileSet is a group of files. These files can be found in a directory tree starting in a base directory and are matched by patterns taken from a number of PatternSets and Selectors.

PatternSets can be specified as nested `<patternset>` elements. In addition, FileSet holds an implicit PatternSet and supports the nested `<include>`, `<includesfile>`, `<exclude>` and `<excludesfile>` elements of PatternSet directly, as well as PatternSet's attributes.

Selectors are available as nested elements within the FileSet. If any of the selectors within the FileSet do not select the file, the file is not considered part of the FileSet. This makes a FileSet equivalent to an `<and>` selector container.

Attribute | Description | Required
--- | --- | ---
dir | the root of the directory tree of this FileSet. | Exactly one of 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`). | No; defaults to yes
includes | comma- or space-separated list of patterns of files that must be included. | No; defaults to all files
includesfile | name of a file; each line of this file is taken to be an include pattern. Note: if the file is empty and there are no other patterns defined for the fileset, all files will be included. | No
excludes | comma- or space-separated list of patterns of files that must be excluded. | No; defaults to default excludes or none if defaultexcludes is no
excludesfile | 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? | No; defaults to true
followsymlinks | Shall symbolic links and Windows junctions be followed? See the note below. Windows junctions are detected since Ant 1.10.16. | No; defaults to true
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. Since Apache Ant 1.7.1 | No; defaults to true (for backward compatibility reasons)
refid | Makes this `fileset` a reference to a `fileset` defined elsewhere. If specified no other attributes or nested elements are allowed. | No

Note: Prior to Ant 1.10.2 all files/directories for which the canonical path is different from its path are considered symbolic links. On Unix systems this usually means the file really is a symbolic link but it may lead to false results on other platforms.

Starting with Ant 1.10.2 Ant relies on `Files#isSymbolicLink` which is supposed to work reliable on all platforms.

Starting with Ant 1.10.16 Ant will also detect Windows junctions and treat them just like symbolic links in most cases.

Full support for symbolic links is still lacking (notably, in Zip files). Currently, the semantics of followsymlinks in FileSet is such that false excludes symbolic links and Windows junctions completely, and true allows symbolic links and junctions to be considered by selectors, which may have their own followsymlinks attributes with proper semantics; i.e., false allows selector to inspect properties of a symbolic link or junction itself, and true those of its target.

#### Examples

    <fileset dir="${server.src}" casesensitive="yes">
      <include name="**/*.java"/>
      <exclude name="**/*Test*"/>
    </fileset>

Groups all files in directory `${server.src}` that are Java source files and don't have the text `Test` in their name.

    <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 establishes a 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 the same 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`).