You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

fileset.html 7.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>FileSet Type</title>
  20. </head>
  21. <body>
  22. <h2><a name="fileset">FileSet</a></h2>
  23. <p>A FileSet is a group of files. These files can be found in a
  24. directory tree starting in a base directory and are matched by
  25. patterns taken from a number of <a
  26. href="patternset.html">PatternSets</a> and
  27. <a href="selectors.html">Selectors</a>.
  28. <p>PatternSets can be specified as nested
  29. <code>&lt;patternset&gt;</code> elements. In addition, FileSet holds
  30. an implicit PatternSet and supports the nested
  31. <code>&lt;include&gt;</code>, <code>&lt;includesfile&gt;</code>,
  32. <code>&lt;exclude&gt;</code> and <code>&lt;excludesfile&gt;</code>
  33. elements of PatternSet directly, as well as PatternSet's
  34. attributes.</p>
  35. <p>Selectors are available as nested elements within the FileSet.
  36. If any of the selectors within the FileSet do not select the file, the
  37. file is not considered part of the FileSet. This makes a FileSet
  38. equivalent to an <code>&lt;and&gt;</code> selector container.</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. <td align="center" valign="top"><b>Required</b></td>
  44. </tr>
  45. <tr>
  46. <td valign="top">dir</td>
  47. <td valign="top">the root of the directory tree of this FileSet.</td>
  48. <td valign="middle" align="center" rowspan="2">Exactly one of dir or file must be specified</td>
  49. </tr>
  50. <tr>
  51. <td valign="top">file</td>
  52. <td valign="top">shortcut for specifying a single-file fileset</td>
  53. </tr>
  54. <tr>
  55. <td valign="top">defaultexcludes</td>
  56. <td valign="top">indicates whether <a href="../dirtasks.html#defaultexcludes">default excludes</a> should be used or not
  57. (<code>yes | no</code>); default excludes are used when omitted.</td>
  58. <td valign="top" align="center">No</td>
  59. </tr>
  60. <tr>
  61. <td valign="top">includes</td>
  62. <td valign="top">comma- or space-separated list of patterns of files that must be
  63. included; all files are included when omitted.</td>
  64. <td valign="top" align="center">No</td>
  65. </tr>
  66. <tr>
  67. <td valign="top">includesfile</td>
  68. <td valign="top">the name of a file; each line of this file is
  69. taken to be an include pattern.<br/>
  70. <b>Note:</b> if the file is empty and there are no other
  71. patterns defined for the fileset, all files will be included.
  72. </td>
  73. <td valign="top" align="center">No</td>
  74. </tr>
  75. <tr>
  76. <td valign="top">excludes</td>
  77. <td valign="top">comma- or space-separated list of patterns of files that must be
  78. excluded; no files (except default excludes) are excluded when omitted.</td>
  79. <td valign="top" align="center">No</td>
  80. </tr>
  81. <tr>
  82. <td valign="top">excludesfile</td>
  83. <td valign="top">the name of a file; each line of this file is
  84. taken to be an exclude pattern.</td>
  85. <td valign="top" align="center">No</td>
  86. </tr>
  87. <tr>
  88. <td valign="top">casesensitive</td>
  89. <td valign="top">Must the include and exclude patterns be treated in a case sensitive way?
  90. Defaults to true.</td>
  91. <td valign="top" align="center">No</td>
  92. </tr>
  93. <tr>
  94. <td valign="top">followsymlinks</td>
  95. <td valign="top">Shall symbolic links be followed? Defaults to
  96. true. See the note <a href="#symlink">below</a>.</td>
  97. <td valign="top" align="center">No</td>
  98. </tr>
  99. <tr>
  100. <td valign="top">erroronmissingdir</td>
  101. <td valign="top">
  102. Specify what happens if the base directory does not exist.
  103. If true a build error will happen, if false, the fileset
  104. will be ignored/empty.
  105. Defaults to true.
  106. <em>Since Apache Ant 1.7.1 (default is true for backward compatibility
  107. reasons.)</em>
  108. </td>
  109. <td valign="top" align="center">No</td>
  110. </tr>
  111. </table>
  112. <p><a name="symlink"><b>Note</b></a>: All files/directories for which
  113. the canonical path is different from its path are considered symbolic
  114. links. On Unix systems this usually means the file really is a
  115. symbolic link but it may lead to false results on other
  116. platforms.</p>
  117. <h4>Examples</h4>
  118. <blockquote><pre>
  119. &lt;fileset dir=&quot;${server.src}&quot; casesensitive=&quot;yes&quot;&gt;
  120. &lt;include name=&quot;**/*.java&quot;/&gt;
  121. &lt;exclude name=&quot;**/*Test*&quot;/&gt;
  122. &lt;/fileset&gt;
  123. </pre></blockquote>
  124. <p>Groups all files in directory <code>${server.src}</code> that are Java
  125. source files and don't have the text <code>Test</code> in their
  126. name.</p>
  127. <blockquote><pre>
  128. &lt;fileset dir=&quot;${server.src}&quot; casesensitive=&quot;yes&quot;&gt;
  129. &lt;patternset id=&quot;non.test.sources&quot;&gt;
  130. &lt;include name=&quot;**/*.java&quot;/&gt;
  131. &lt;exclude name=&quot;**/*Test*&quot;/&gt;
  132. &lt;/patternset&gt;
  133. &lt;/fileset&gt;
  134. </pre></blockquote>
  135. <p>Groups the same files as the above example, but also establishes
  136. a PatternSet that can be referenced in other
  137. <code>&lt;fileset&gt;</code> elements, rooted at a different directory.</p>
  138. <blockquote><pre>
  139. &lt;fileset dir=&quot;${client.src}&quot; &gt;
  140. &lt;patternset refid=&quot;non.test.sources&quot;/&gt;
  141. &lt;/fileset&gt;
  142. </pre></blockquote>
  143. <p>Groups all files in directory <code>${client.src}</code>, using the
  144. same patterns as the above example.</p>
  145. <blockquote><pre>
  146. &lt;fileset dir=&quot;${server.src}&quot; casesensitive=&quot;yes&quot;&gt;
  147. &lt;filename name=&quot;**/*.java&quot;/&gt;
  148. &lt;filename name=&quot;**/*Test*&quot; negate=&quot;true&quot;/&gt;
  149. &lt;/fileset&gt;
  150. </pre></blockquote>
  151. <p>Groups the same files as the top example, but using the
  152. <code>&lt;filename&gt;</code> selector.</p>
  153. <blockquote><pre>
  154. &lt;fileset dir=&quot;${server.src}&quot; casesensitive=&quot;yes&quot;&gt;
  155. &lt;filename name=&quot;**/*.java&quot;/&gt;
  156. &lt;not&gt;
  157. &lt;filename name=&quot;**/*Test*&quot;/&gt;
  158. &lt;/not&gt;
  159. &lt;/fileset&gt;
  160. </pre></blockquote>
  161. <p>Groups the same files as the previous example using a combination of the
  162. <code>&lt;filename&gt;</code> selector and the <code>&lt;not&gt;</code>
  163. selector container.</p>
  164. <blockquote><pre>
  165. &lt;fileset dir="src" includes="main/" /&gt;
  166. </pre></blockquote>
  167. <p>Selects all files in <i>src/main</i> (e.g. <i>src/main/Foo.java</i> or
  168. <i>src/main/application/Bar.java</i>).</p>
  169. </body>
  170. </html>