Apache Ant/Fileset

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.

FileSet identifies the base directory tree with its dir attribute. Then the FileSet's enclosed pattern elements, both named (PatternSets) and selected by wildcards (Selectors), choose the files and folders within the base tree.

If any selector within the FileSet do not select a given file, that file is not considered part of the FileSet. This makes FileSets equivalent to an selector container.

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.

Examples
The below FileSets all select the files in directory ${server.src} that are Java source files without "Test" in their name.

  

   

 

  

  

Finally
FileSets can appear as children of the project element or inside tasks that support this feature.

Next Section, Next Cookbook Chapter