Concepts and Types - TypesPatternSetPatternSetPatterns can be grouped tosets and later be referenced by their id attribute. Theyare defined via a patternset element, which can appearnested into a FileSet or a directory-basedtask that constitutes an implicit FileSet. In addition,patternset s can be defined as a stand alone element atthe same level as target i.e., as children ofproject as well as as children oftarget . Patterns can be specified by nested<include> , or <exclude> elementsor the following attributes. Attribute | Description | includes | comma- or space-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. You can specify more than one include file by using a nested includesfile elements. | excludes | comma- or space-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. You can specify more than one exclude file by using a nested excludesfile elements. | Parameters specified as nested elementsinclude and exclude
Each such element defines a single pattern for files to include orexclude. includesfile and excludesfile
If you want to list the files to include or exclude external toyour build file, you should use the includesfile/excludesfileattributes or elements. Using the attribute, you can only specify asingle file of each type, while the nested elements can be specifiedmore than once - the nested elements also support if/unless attributesyou can use to test the existance of a property. patternset
Patternsets may be nested within one another, adding the nestedpatterns to the parent patternset. invert
A nested patternset can be inverted using the <invert> element. Since Apache Ant 1.7.1 Examples<patternset id="non.test.sources"> <include name="**/*.java"/> <exclude name="**/*Test*"/></patternset>
Builds a set of patterns that matches all .java filesthat do not contain the text Test in their name. This setcan be referred to via<patternset refid="non.test.sources"/> ,by tasks that support this feature, or by FileSets. Note that while the includes andexcludes attributes acceptmultiple elements separated by commas or spaces, the nested<include> and <exclude> elements expect their nameattribute to hold a single pattern. The nested elements allow you to use if and unless arguments tospecify that the element should only be used if a property is set, orthat 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 propertyprofessional is set to some value. The two sets <patternset includesfile="some-file"/>
and <patternset> <includesfile name="some-file"/> <patternset/>
are identical. The include patterns will be read from the filesome-file , one pattern per line. <patternset> <includesfile name="some-file"/> <includesfile name="${some-other-file}" if="some-other-file" /> <patternset/>
will also read include patterns from the file the propertysome-other-file points to, if a property of that name hasbeen defined. |