Apache Ant/Fileset
From Wikibooks, the open-content textbooks collection
FileSets are ant's way of creating groups of files to do work on. 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. FileSets can appear inside tasks that support this feature or at the same level as target - i.e., as children of project.
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 FileSets equivalent to an <and> selector container.
[edit] Wildcards
Wildcards are used by ant to specify groups of files that have a pattern to their names.
- ? is used to match any character.
- * is used to match zero or more characters.
- ** is used to match zero or more directories.
[edit] 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>
<fileset dir="${client.src}">
<patternset refid="non.test.sources"/>
</fileset>
<fileset dir="${server.src}" casesensitive="yes">
<filename name="**/*.java"/>
<filename name="**/*Test*" negate="true"/>
</fileset>
<fileset dir="${server.src}" casesensitive="yes">
<filename name="**/*.java"/>
<not>
<filename name="**/*Test*"/>
</not>
</fileset>