[14982] | 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
|
---|
| 29 | sets and later be referenced by their <code>id</code> attribute. They
|
---|
| 30 | are defined via a <code>patternset</code> element, which can appear
|
---|
| 31 | nested into a <a href="fileset.html">FileSet</a> or a directory-based
|
---|
| 32 | task that constitutes an implicit FileSet. In addition,
|
---|
| 33 | <code>patternset</code>s can be defined as a stand alone element at
|
---|
| 34 | the same level as <code>target</code> — 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><include></code>, or <code><exclude></code> elements
|
---|
| 38 | or 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
|
---|
| 70 | exclude.</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
|
---|
| 97 | your build file, you should use the includesfile/excludesfile
|
---|
| 98 | attributes or elements. Using the attribute, you can only specify a
|
---|
| 99 | single file of each type, while the nested elements can be specified
|
---|
| 100 | more than once - the nested elements also support if/unless attributes
|
---|
| 101 | you 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
|
---|
| 128 | patterns to the parent patternset.</p>
|
---|
| 129 | <h3>Examples</h3>
|
---|
| 130 | <blockquote><pre>
|
---|
| 131 | <patternset id="non.test.sources">
|
---|
| 132 | <include name="**/*.java"/>
|
---|
| 133 | <exclude name="**/*Test*"/>
|
---|
| 134 | </patternset>
|
---|
| 135 | </pre></blockquote>
|
---|
| 136 | <p>Builds a set of patterns that matches all <code>.java</code> files
|
---|
| 137 | that do not contain the text <code>Test</code> in their name. This set
|
---|
| 138 | can be <a href="../using.html#references">referred</a> to via
|
---|
| 139 | <code><patternset refid="non.test.sources"/></code>,
|
---|
| 140 | by 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
|
---|
| 143 | multiple elements separated by commas or spaces, the nested
|
---|
| 144 | <code><include></code> and <code><exclude></code> elements expect their name
|
---|
| 145 | attribute to hold a single pattern.</p>
|
---|
| 146 | <p>The nested elements allow you to use if and unless arguments to
|
---|
| 147 | specify that the element should only be used if a property is set, or
|
---|
| 148 | that it should be used only if a property is not set.</p>
|
---|
| 149 | <p>For example</p>
|
---|
| 150 | <blockquote><pre>
|
---|
| 151 | <patternset id="sources">
|
---|
| 152 | <include name="std/**/*.java"/>
|
---|
| 153 | <include name="prof/**/*.java" if="professional"/>
|
---|
| 154 | <exclude name="**/*Test*"/>
|
---|
| 155 | </patternset>
|
---|
| 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 | <patternset includesfile="some-file"/>
|
---|
| 162 | </pre></blockquote>
|
---|
| 163 | <p>and</p>
|
---|
| 164 | <blockquote><pre>
|
---|
| 165 | <patternset>
|
---|
| 166 | <includesfile name="some-file"/>
|
---|
| 167 | <patternset/>
|
---|
| 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 | <patternset>
|
---|
| 173 | <includesfile name="some-file"/>
|
---|
| 174 | <includesfile name="${some-other-file}"
|
---|
| 175 | if="some-other-file"
|
---|
| 176 | />
|
---|
| 177 | <patternset/>
|
---|
| 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
|
---|
| 181 | been defined.</p>
|
---|
| 182 |
|
---|
| 183 |
|
---|
| 184 | </body>
|
---|
| 185 | </html>
|
---|
| 186 |
|
---|