blob: 491a62f0848bf5717d8a65ccc532fe0d6e5dd1f5 [file] [log] [blame]
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>Ant User Manual</title>
</head>
<body>
<h2><a name="patternset">PatternSet</a></h2>
<p>Patterns can be grouped to sets and later be referenced by their
<code>id</code>
attribute. They are defined via a <code>patternset</code> element,
which can appear nested into a <a href="fileset.html">FileSet</a> or a
directory-based task that constitutes an implicit FileSet. In addition,
<code>patternset</code>s can be defined at the same level as
<code>target</code> &#151; i.e., as children of <code>project</code>.</p>
<p>Patterns can be specified by nested <code>&lt;include&gt;</code> or
<code>&lt;exclude&gt;</code> elements or the following attributes.</p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
</tr>
<tr>
<td valign="top">includes</td>
<td valign="top">comma-separated list of patterns of files that must be
included. All files are included when omitted.</td>
</tr>
<tr>
<td valign="top">includesfile</td>
<td valign="top">the name of a file; each line of this file is
taken to be an include pattern.</td>
</tr>
<tr>
<td valign="top">excludes</td>
<td valign="top">comma-separated list of patterns of files that must be
excluded; no files (except default excludes) are excluded when omitted.</td>
</tr>
<tr>
<td valign="top">excludesfile</td>
<td valign="top">the name of a file; each line of this file is
taken to be an exclude pattern.</td>
</tr>
</table>
<h4>Examples</h4>
<blockquote><pre>
&lt;patternset id=&quot;non.test.sources&quot; &gt;
&lt;include name=&quot;**/*.java&quot;/&gt;
&lt;exclude name=&quot;**/*Test*&quot;/&gt;
&lt;/patternset&gt;
</pre></blockquote>
<p>Builds a set of patterns that matches all <code>.java</code> files
that do not contain the text <code>Test</code> in their name. This set
can be <a href="../using.html#references">referred</a> to via
<code>&lt;patternset refid=&quot;non.test.sources&quot;/&gt;</code>,
by tasks that support this feature, or by FileSets.</p>
<p>Note that while the <code>includes</code> and
<code>excludes</code> attributes accept
multiple elements separated by commas or spaces, the nested
&lt;include&gt; and &lt;exclude&gt; elements expect their name
attribute to hold a single pattern.</p>
<p>The nested &lt;include&gt; and &lt;exclude&gt; 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.</p>
<p>For example</p>
<blockquote><pre>
&lt;patternset id=&quot;sources&quot; &gt;
&lt;include name=&quot;std/**/*.java&quot;/&gt;
&lt;include name=&quot;prof/**/*.java&quot; if=&quot;professional&quot;/&gt;
&lt;exclude name=&quot;**/*Test*&quot;/&gt;
&lt;/patternset&gt;
</pre></blockquote>
<p>will only include the files in the sub-directory <em>prof</em> if the property
<em>professional</em> is set to some value.</p>
<hr>
<p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
Reserved.</p>
</body>
</html>