source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/docs/manual/CoreTypes/patternset.html@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 6.5 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Language" content="en-us">
5<title>PatternSet Type</title>
6<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
7</head>
8
9<body>
10
11<h2><a name="patternset">PatternSet</a></h2>
12<p><a href="../dirtasks.html#patterns">Patterns</a> can be grouped to
13sets and later be referenced by their <code>id</code> attribute. They
14are defined via a <code>patternset</code> element, which can appear
15nested into a <a href="fileset.html">FileSet</a> or a directory-based
16task that constitutes an implicit FileSet. In addition,
17<code>patternset</code>s can be defined as a stand alone element at
18the same level as <code>target</code> &#151; i.e., as children of
19<code>project</code> as well as as children of
20<code>target</code>.</p> <p>Patterns can be specified by nested
21<code>&lt;include&gt;</code>, or <code>&lt;exclude&gt;</code> elements
22or the following attributes.</p>
23<table border="1" cellpadding="2" cellspacing="0">
24 <tr>
25 <td valign="top"><b>Attribute</b></td>
26 <td valign="top"><b>Description</b></td>
27 </tr>
28 <tr>
29 <td valign="top">includes</td>
30 <td valign="top">comma- or space-separated list of patterns of files that must be
31 included. All files are included when omitted.</td>
32 </tr>
33 <tr>
34 <td valign="top">includesfile</td>
35 <td valign="top">the name of a file; each line of this file is
36 taken to be an include pattern. You can specify more than one
37 include file by using a nested includesfile elements.</td>
38 </tr>
39 <tr>
40 <td valign="top">excludes</td>
41 <td valign="top">comma- or space-separated list of patterns of files that must be
42 excluded; no files (except default excludes) are excluded when omitted.</td>
43 </tr>
44 <tr>
45 <td valign="top">excludesfile</td>
46 <td valign="top">the name of a file; each line of this file is
47 taken to be an exclude pattern. You can specify more than one
48 exclude file by using a nested excludesfile elements.</td>
49 </tr>
50</table>
51<h3>Parameters specified as nested elements</h3>
52<h4><code>include</code> and <code>exclude</code></h4>
53<p>Each such element defines a single pattern for files to include or
54exclude.</p>
55<table border="1" cellpadding="2" cellspacing="0">
56 <tr>
57 <td valign="top"><b>Attribute</b></td>
58 <td valign="top"><b>Description</b></td>
59 <td align="center" valign="top"><b>Required</b></td>
60 </tr>
61 <tr>
62 <td valign="top">name</td>
63 <td valign="top">the <a href="../dirtasks.html#patterns">pattern</a>
64 to in/exclude.</td>
65 <td align="center" valign="top">Yes</td>
66 </tr>
67 <tr>
68 <td valign="top">if</td>
69 <td valign="top">Only use this pattern if the named property is set.</td>
70 <td align="center" valign="top">No</td>
71 </tr>
72 <tr>
73 <td valign="top">unless</td>
74 <td valign="top">Only use this pattern if the named property is
75 <b>not</b> set.</td>
76 <td align="center" valign="top">No</td>
77 </tr>
78</table>
79<h4><code>includesfile</code> and <code>excludesfile</code></h4>
80<p>If you want to list the files to include or exclude external to
81your build file, you should use the includesfile/excludesfile
82attributes or elements. Using the attribute, you can only specify a
83single file of each type, while the nested elements can be specified
84more than once - the nested elements also support if/unless attributes
85you can use to test the existance of a property.</p>
86<table border="1" cellpadding="2" cellspacing="0">
87 <tr>
88 <td valign="top"><b>Attribute</b></td>
89 <td valign="top"><b>Description</b></td>
90 <td align="center" valign="top"><b>Required</b></td>
91 </tr>
92 <tr>
93 <td valign="top">name</td>
94 <td valign="top">the name of the file holding the patterns to
95 in/exclude.</td>
96 <td align="center" valign="top">Yes</td>
97 </tr>
98 <tr>
99 <td valign="top">if</td>
100 <td valign="top">Only read this file if the named property is set.</td>
101 <td align="center" valign="top">No</td>
102 </tr>
103 <tr>
104 <td valign="top">unless</td>
105 <td valign="top">Only read this file if the named property is
106 <b>not</b> set.</td>
107 <td align="center" valign="top">No</td>
108 </tr>
109</table>
110<h4><code>patternset</code></h4>
111<p>Patternsets may be nested within one another, adding the nested
112patterns to the parent patternset.</p>
113<h3>Examples</h3>
114<blockquote><pre>
115&lt;patternset id=&quot;non.test.sources&quot;&gt;
116 &lt;include name=&quot;**/*.java&quot;/&gt;
117 &lt;exclude name=&quot;**/*Test*&quot;/&gt;
118&lt;/patternset&gt;
119</pre></blockquote>
120<p>Builds a set of patterns that matches all <code>.java</code> files
121that do not contain the text <code>Test</code> in their name. This set
122can be <a href="../using.html#references">referred</a> to via
123<code>&lt;patternset refid=&quot;non.test.sources&quot;/&gt;</code>,
124by tasks that support this feature, or by FileSets.</p>
125<p>Note that while the <code>includes</code> and
126<code>excludes</code> attributes accept
127multiple elements separated by commas or spaces, the nested
128<code>&lt;include&gt;</code> and <code>&lt;exclude&gt;</code> elements expect their name
129attribute to hold a single pattern.</p>
130<p>The nested elements allow you to use if and unless arguments to
131specify that the element should only be used if a property is set, or
132that it should be used only if a property is not set.</p>
133<p>For example</p>
134<blockquote><pre>
135&lt;patternset id=&quot;sources&quot;&gt;
136 &lt;include name=&quot;std/**/*.java&quot;/&gt;
137 &lt;include name=&quot;prof/**/*.java&quot; if=&quot;professional&quot;/&gt;
138 &lt;exclude name=&quot;**/*Test*&quot;/&gt;
139&lt;/patternset&gt;
140</pre></blockquote>
141<p>will only include the files in the sub-directory <em>prof</em> if the property
142<em>professional</em> is set to some value.</p>
143<p>The two sets</p>
144<blockquote><pre>
145&lt;patternset includesfile=&quot;some-file&quot;/&gt;
146</pre></blockquote>
147<p>and</p>
148<blockquote><pre>
149&lt;patternset&gt;
150 &lt;includesfile name=&quot;some-file&quot;/&gt;
151&lt;patternset/&gt;
152</pre></blockquote>
153<p>are identical. The include patterns will be read from the file
154<code>some-file</code>, one pattern per line.</p>
155<blockquote><pre>
156&lt;patternset&gt;
157 &lt;includesfile name=&quot;some-file&quot;/&gt;
158 &lt;includesfile name=&quot;${some-other-file}&quot;
159 if=&quot;some-other-file&quot;
160 /&gt;
161&lt;patternset/&gt;
162</pre></blockquote>
163<p>will also read include patterns from the file the property
164<code>some-other-file</code> points to, if a property of that name has
165been defined.</p>
166<hr>
167<p align="center">Copyright &copy; 2000-2002,2004 The Apache Software Foundation. All rights
168Reserved.</p>
169
170</body>
171</html>
172
Note: See TracBrowser for help on using the repository browser.