source: other-projects/trunk/realistic-books/packages/AntInstaller/web/manual/manual/CoreTypes/patternset.html@ 19253

Last change on this file since 19253 was 19253, checked in by davidb, 15 years ago

Establishing a source code repository for Veronica's Realistic Book's software

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