PatternSet

Patterns can be grouped to sets and later be referenced by their id attribute. They are defined via a patternset element, which can appear nested into a FileSet or a directory-based task that constitutes an implicit FileSet. In addition, patternsets can be defined at the same level as target — i.e., as children of project.

Patterns can be specified by nested <include> or <exclude> elements or the following attributes.

Attribute Description
includes comma-separated list of patterns of files that must be included. All files are included when omitted.
includesfile the name of a file; each line of this file is taken to be an include pattern.
excludes comma-separated list of patterns of files that must be excluded; no files (except default excludes) are excluded when omitted.
excludesfile the name of a file; each line of this file is taken to be an exclude pattern.

Examples

<patternset id="non.test.sources" >
  <include name="**/*.java"/>
  <exclude name="**/*Test*"/>
</patternset>

Builds a set of patterns that matches all .java files that do not contain the text Test in their name. This set can be referred to via <patternset refid="non.test.sources"/>, by tasks that support this feature, or by FileSets.

Note that while the includes and excludes attributes accept multiple elements separated by commas or spaces, the nested <include> and <exclude> elements expect their name attribute to hold a single pattern.

The nested <include> and <exclude> elements allow you to use if and unless arguments to specify that the element should only be used if a property is set, or that it should be used only if a property is not set.

For example

<patternset id="sources" >
  <include name="std/**/*.java"/>
  <include name="prof/**/*.java" if="professional"/>
  <exclude name="**/*Test*"/>
</patternset>

will only include the files in the sub-directory prof if the property professional is set to some value.


Copyright © 2000,2001 Apache Software Foundation. All rights Reserved.