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 6.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 id="fileset">FileSet</h2>
  23. <p>A FileSet is a group of files. These files can be found in a directory tree starting in a
  24. base directory and are matched by patterns taken from a number
  25. of <a href="patternset.html">PatternSets</a> and <a href="selectors.html">Selectors</a>.</p>
  26. <p>PatternSets can be specified as nested <code>&lt;patternset&gt;</code> elements. In
  27. addition, FileSet holds an implicit PatternSet and supports the
  28. nested <code>&lt;include&gt;</code>, <code>&lt;includesfile&gt;</code>, <code>&lt;exclude&gt;</code>
  29. and <code>&lt;excludesfile&gt;</code> elements of PatternSet directly, as well as PatternSet's
  30. attributes.</p>
  31. <p>Selectors are available as nested elements within the FileSet. If any of the selectors
  32. within the FileSet do not select the file, the file is not considered part of the FileSet. This
  33. makes a FileSet equivalent to an <code>&lt;and&gt;</code> selector container.</p>
  34. <table class="attr">
  35. <tr>
  36. <th>Attribute</th>
  37. <th>Description</th>
  38. <th>Required</th>
  39. </tr>
  40. <tr>
  41. <td>dir</td>
  42. <td>the root of the directory tree of this FileSet.</td>
  43. <td rowspan="2">Exactly one of dir or file must be specified</td>
  44. </tr>
  45. <tr>
  46. <td>file</td>
  47. <td class="left">shortcut for specifying a single-file fileset</td>
  48. </tr>
  49. <tr>
  50. <td>defaultexcludes</td>
  51. <td>indicates whether <a href="../dirtasks.html#defaultexcludes">default excludes</a> should
  52. be used or not (<code>yes|no</code>).</td>
  53. <td>No; defaults to <q>yes</q></td>
  54. </tr>
  55. <tr>
  56. <td>includes</td>
  57. <td>comma- or space-separated list of patterns of files that must be included.</td>
  58. <td>No; defaults to all files</td>
  59. </tr>
  60. <tr>
  61. <td>includesfile</td>
  62. <td>name of a file; each line of this file is taken to be an include pattern.<br/>
  63. <strong>Note</strong>: if the file is empty and there are no other patterns defined for
  64. the fileset, all files will be included.
  65. </td>
  66. <td>No</td>
  67. </tr>
  68. <tr>
  69. <td>excludes</td>
  70. <td>comma- or space-separated list of patterns of files that must be excluded.</td>
  71. <td>No; defaults to default excludes or none if <var>defaultexcludes</var> is <q>no</q></td>
  72. </tr>
  73. <tr>
  74. <td>excludesfile</td>
  75. <td>name of a file; each line of this file is taken to be an exclude pattern.</td>
  76. <td>No</td>
  77. </tr>
  78. <tr>
  79. <td>casesensitive</td>
  80. <td>Must the include and exclude patterns be treated in a case sensitive way?</td>
  81. <td>No; defaults to <q>true</q></td>
  82. </tr>
  83. <tr>
  84. <td>followsymlinks</td>
  85. <td>Shall symbolic links be followed? See the note <a href="#symlink">below</a>.</td>
  86. <td>No; defaults to <q>true</q></td>
  87. </tr>
  88. <tr>
  89. <td>erroronmissingdir</td>
  90. <td>
  91. Specify what happens if the base directory does not exist. If <q>true</q> a build error
  92. will happen, if <q>false</q>, the fileset will be ignored/empty.
  93. <em>Since Apache Ant 1.7.1</em>
  94. </td>
  95. <td>No; defaults to <q>true</q> (for backward compatibility reasons)</td>
  96. </tr>
  97. </table>
  98. <p id="symlink"><strong>Note</strong>: All files/directories for which the canonical path is
  99. different from its path are considered symbolic links. On Unix systems this usually means the
  100. file really is a symbolic link but it may lead to false results on other platforms.</p>
  101. <h4>Examples</h4>
  102. <pre>
  103. &lt;fileset dir=&quot;${server.src}&quot; casesensitive=&quot;yes&quot;&gt;
  104. &lt;include name=&quot;**/*.java&quot;/&gt;
  105. &lt;exclude name=&quot;**/*Test*&quot;/&gt;
  106. &lt;/fileset&gt;
  107. </pre>
  108. <p>Groups all files in directory <samp>${server.src}</samp> that are Java source files and don't
  109. have the text <samp>Test</samp> in their name.</p>
  110. <pre>
  111. &lt;fileset dir=&quot;${server.src}&quot; casesensitive=&quot;yes&quot;&gt;
  112. &lt;patternset id=&quot;non.test.sources&quot;&gt;
  113. &lt;include name=&quot;**/*.java&quot;/&gt;
  114. &lt;exclude name=&quot;**/*Test*&quot;/&gt;
  115. &lt;/patternset&gt;
  116. &lt;/fileset&gt;
  117. </pre>
  118. <p>Groups the same files as the above example, but also establishes a PatternSet that can be
  119. referenced in other <code>&lt;fileset&gt;</code> elements, rooted at a different directory.</p>
  120. <pre>
  121. &lt;fileset dir=&quot;${client.src}&quot; &gt;
  122. &lt;patternset refid=&quot;non.test.sources&quot;/&gt;
  123. &lt;/fileset&gt;
  124. </pre>
  125. <p>Groups all files in directory <samp>${client.src}</samp>, using the same patterns as the
  126. above example.</p>
  127. <pre>
  128. &lt;fileset dir=&quot;${server.src}&quot; casesensitive=&quot;yes&quot;&gt;
  129. &lt;filename name=&quot;**/*.java&quot;/&gt;
  130. &lt;filename name=&quot;**/*Test*&quot; negate=&quot;true&quot;/&gt;
  131. &lt;/fileset&gt;
  132. </pre>
  133. <p>Groups the same files as the top example, but using the <code>&lt;filename&gt;</code>
  134. selector.</p>
  135. <pre>
  136. &lt;fileset dir=&quot;${server.src}&quot; casesensitive=&quot;yes&quot;&gt;
  137. &lt;filename name=&quot;**/*.java&quot;/&gt;
  138. &lt;not&gt;
  139. &lt;filename name=&quot;**/*Test*&quot;/&gt;
  140. &lt;/not&gt;
  141. &lt;/fileset&gt;
  142. </pre>
  143. <p>Groups the same files as the previous example using a combination of
  144. the <code>&lt;filename&gt;</code> selector and the <code>&lt;not&gt;</code> selector
  145. container.</p>
  146. <pre>&lt;fileset dir="src" includes="main/"/&gt;</pre>
  147. <p>Selects all files in <samp>src/main</samp> (e.g. <samp>src/main/Foo.java</samp>
  148. or <samp>src/main/application/Bar.java</samp>).</p>
  149. </body>
  150. </html>