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.

resources.html 49 KiB

10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  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>Resources and Resource Collections</title>
  20. </head>
  21. <body>
  22. <h2 id="resource">Resources</h2>
  23. <p>
  24. A file-like entity can be abstracted to the concept of a <i>resource</i>.
  25. In addition to providing access to file-like attributes, a resource
  26. implementation should, when possible, provide the means to read content
  27. from and/or write content to the underlying entity. Although the resource
  28. concept was introduced in <i>Apache Ant 1.5.2</i>, resources are available for
  29. explicit use beginning in <b>Ant 1.7</b>.
  30. </p>
  31. <h3>The built-in resource types are:</h3>
  32. <ul>
  33. <li><a href="#basic">resource</a> - a basic resource.</li>
  34. <li><a href="#bzip2resource">bzip2resource</a> - a BZip2 compressed resource.</li>
  35. <li><a href="#file">file</a> - a file.</li>
  36. <li><a href="#gzipresource">gzipresource</a> - a GZip compressed resource.</li>
  37. <li><a href="#javaresource">javaresource</a> - a resource loadable
  38. via a Java classloader.</li>
  39. <li><a href="#javaconstant">javaconstant</a> - a constant in a class loadable
  40. via a Java classloader.</li>
  41. <li><a href="#propertyresource">propertyresource</a> - an Ant property.</li>
  42. <li><a href="#string">string</a> - a text string.</li>
  43. <li><a href="#tarentry">tarentry</a> - an entry in a tar file.</li>
  44. <li><a href="#url">url</a> - a URL.</li>
  45. <li><a href="#xzresource">xzresource</a> - an XZ compressed resource.</li>
  46. <li><a href="#zipentry">zipentry</a> - an entry in a zip file.</li>
  47. </ul>
  48. <h4 id="basic">resource</h4>
  49. <p>A basic resource. Other resource types derive from this basic
  50. type; as such all its attributes are available, though in most cases
  51. irrelevant attributes will be ignored. This and all resource
  52. implementations are also usable as single-element
  53. <a href="#collection">Resource Collections</a>.
  54. </p>
  55. <table>
  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 name of this resource</td>
  64. <td align="center" valign="top">No</td>
  65. </tr>
  66. <tr>
  67. <td valign="top">exists</td>
  68. <td valign="top">Whether this resource exists</td>
  69. <td align="center" valign="top">No, default <i>true</i></td>
  70. </tr>
  71. <tr>
  72. <td valign="top">lastmodified</td>
  73. <td valign="top">The last modification time of this resource</td>
  74. <td align="center" valign="top">No</td>
  75. </tr>
  76. <tr>
  77. <td valign="top">directory</td>
  78. <td valign="top">Whether this resource is directory-like</td>
  79. <td align="center" valign="top">No, default <i>false</i></td>
  80. </tr>
  81. <tr>
  82. <td valign="top">size</td>
  83. <td valign="top">The size of this resource</td>
  84. <td align="center" valign="top">No</td>
  85. </tr>
  86. </table>
  87. <h4 id="file">file</h4>
  88. <p>Represents a file accessible via local filesystem conventions.</p>
  89. <table>
  90. <tr>
  91. <td valign="top"><b>Attribute</b></td>
  92. <td valign="top"><b>Description</b></td>
  93. <td align="center" valign="top"><b>Required</b></td>
  94. </tr>
  95. <tr>
  96. <td valign="top">file</td>
  97. <td valign="top">The file represented by this resource</td>
  98. <td align="center" valign="top">Yes</td>
  99. </tr>
  100. <tr>
  101. <td valign="top">basedir</td>
  102. <td valign="top">The base directory of this resource. When this
  103. attribute is set, attempts to access the name of the resource
  104. will yield a path relative to this location.</td>
  105. <td align="center" valign="top">No</td>
  106. </tr>
  107. </table>
  108. <h4 id="javaresource">javaresource</h4>
  109. <p>Represents a resource loadable via a Java classloader.</p>
  110. <table>
  111. <tr>
  112. <td valign="top"><b>Attribute</b></td>
  113. <td valign="top"><b>Description</b></td>
  114. <td align="center" valign="top"><b>Required</b></td>
  115. </tr>
  116. <tr>
  117. <td valign="top">name</td>
  118. <td valign="top">The name of the resource.</td>
  119. <td align="center" valign="top">Yes</td>
  120. </tr>
  121. <tr>
  122. <td valign="top">classpath</td>
  123. <td valign="top">the classpath to use when looking up a resource.</td>
  124. <td align="center" valign="top">No</td>
  125. </tr>
  126. <tr>
  127. <td valign="top">classpathref</td>
  128. <td valign="top">the classpath to use when looking up a resource,
  129. given as <a href="../using.html#references">reference</a>
  130. to a <code>&lt;path&gt;</code> defined elsewhere..</td>
  131. <td align="center" valign="top">No</td>
  132. </tr>
  133. <tr>
  134. <td valign="top">loaderRef</td>
  135. <td valign="top">the name of the loader that is
  136. used to load the resource, constructed from the specified classpath.</td>
  137. <td align="center" valign="top">No</td>
  138. </tr>
  139. <tr>
  140. <td valign="top">parentFirst</td>
  141. <td valign="top">Whether to consult the parent classloader first -
  142. the parent classloader most likely is the system classloader -
  143. when using a nested classpath. Defaults
  144. to <code>true</code>.<br/>
  145. <em>Since Ant 1.8.0</em></td>
  146. <td align="center" valign="top">No</td>
  147. </tr>
  148. </table>
  149. <p>The classpath can also be specified as nested classpath element,
  150. where <b>&lt;classpath&gt;</b> is a <a
  151. href="../using.html#path">path-like structure</a>.</p>
  152. <h4 id="javaconstant">javaconstant</h4>
  153. <p>Loads the value of a java constant. As a specialisation of
  154. <a href="#javaresource">javaresource</a> all of its attributes and nested elements are
  155. supported. A constant must be specified as <tt>public static</tt> otherwise it could not be loaded.</p>
  156. <table>
  157. <tr>
  158. <td valign="top"><b>Attribute</b></td>
  159. <td valign="top"><b>Description</b></td>
  160. <td align="center" valign="top"><b>Required</b></td>
  161. </tr>
  162. <tr>
  163. <td valign="top">name</td>
  164. <td valign="top">The name of the resource. Must be specified as full qualified
  165. field name.
  166. </td>
  167. <td align="center" valign="top">Yes</td>
  168. </tr>
  169. </table>
  170. <h5>Examples</h5>
  171. This loads the value of the constant <tt>VERSION</tt> of the <tt>org.acme.Main</tt> class
  172. into the <tt>version</tt>-property. The classpath for finding that class is provided via
  173. nested classpath element.
  174. <pre>&lt;loadresource property=&quot;version&quot;&gt;
  175. &lt;javaconstant name=&quot;org.acme.Main.VERSION&quot;&gt;
  176. &lt;classpath&gt;
  177. &lt;pathelement location=&quot;${acme.lib.dir}&quot;/&gt;
  178. &lt;/classpath&gt;
  179. &lt;/javaconstant&gt;
  180. &lt;/loadresource&gt;
  181. </pre>
  182. Create a new file <tt>c:/temp/org.apache.tools.ant.Main.DEFAULT_BUILD_FILENAME</tt> with the content
  183. of that constant (<tt>build.xml</tt>).
  184. <pre>&lt;copy todir=&quot;c:/temp&quot;&gt;
  185. &lt;javaconstant name=&quot;org.apache.tools.ant.Main.DEFAULT_BUILD_FILENAME&quot;/&gt;
  186. &lt;/copy&gt;</pre>
  187. <h4 id="zipentry">zipentry</h4>
  188. <p>Represents an entry in a ZIP archive. The archive can be specified
  189. using the archive attribute or a nested single-element resource
  190. collection. <code>zipentry</code> only supports file system resources
  191. as nested elements.</p>
  192. <table>
  193. <tr>
  194. <td valign="top"><b>Attribute</b></td>
  195. <td valign="top"><b>Description</b></td>
  196. <td align="center" valign="top"><b>Required</b></td>
  197. </tr>
  198. <tr>
  199. <td valign="top">zipfile or its alias name archive</td>
  200. <td valign="top">The zip file containing this resource</td>
  201. <td align="center" valign="top">Yes, unless a nested resource
  202. collection has been specified.</td>
  203. </tr>
  204. <tr>
  205. <td valign="top">name</td>
  206. <td valign="top">The name of the archived resource</td>
  207. <td align="center" valign="top">Yes</td>
  208. </tr>
  209. <tr>
  210. <td valign="top">encoding</td>
  211. <td valign="top">The encoding of the zipfile</td>
  212. <td align="center" valign="top">No;
  213. platform default used if unspecified</td>
  214. </tr>
  215. </table>
  216. <h4 id="tarentry">tarentry</h4>
  217. <p>Represents an entry in a TAR archive. The archive can be specified
  218. using the archive attribute or a nested single-element resource
  219. collection.</p>
  220. <table>
  221. <tr>
  222. <td valign="top"><b>Attribute</b></td>
  223. <td valign="top"><b>Description</b></td>
  224. <td align="center" valign="top"><b>Required</b></td>
  225. </tr>
  226. <tr>
  227. <td valign="top">archive</td>
  228. <td valign="top">The tar archive containing this resource</td>
  229. <td align="center" valign="top">Yes, unless a nested resource
  230. collection has been specified.</td>
  231. </tr>
  232. <tr>
  233. <td valign="top">name</td>
  234. <td valign="top">The name of the archived resource</td>
  235. <td align="center" valign="top">Yes</td>
  236. </tr>
  237. </table>
  238. <h4 id="gzipresource">gzipresource</h4>
  239. <p>This is not a stand-alone resource, but a wrapper around another
  240. resource providing compression of the resource's contents on the fly.
  241. A single element resource collection must be specified as a nested
  242. element.</p>
  243. <h4 id="bzip2resource">bzip2resource</h4>
  244. <p>This is not a stand-alone resource, but a wrapper around another
  245. resource providing compression of the resource's contents on the fly.
  246. A single element resource collection must be specified as a nested
  247. element.</p>
  248. <h4 id="xzresource">xzresource</h4>
  249. <p>This is not a stand-alone resource, but a wrapper around another
  250. resource providing compression of the resource's contents on the fly.
  251. A single element resource collection must be specified as a nested
  252. element.</p>
  253. <p>XZ compression support has been added with Apache Ant 1.10.1 and
  254. depends on external libraries not included in the Ant distribution.
  255. See <a href="../install.html#librarydependencies">Library
  256. Dependencies</a> for more information.</p>
  257. <h4 id="url">url</h4>
  258. <p>Represents a URL.</p>
  259. <table>
  260. <tr>
  261. <td valign="top"><b>Attribute</b></td>
  262. <td valign="top"><b>Description</b></td>
  263. <td align="center" valign="top"><b>Required</b></td>
  264. </tr>
  265. <tr>
  266. <td valign="top">url</td>
  267. <td valign="top">The url to expose</td>
  268. <td rowspan="3" align="center" valign="middle">Exactly one of these</td>
  269. </tr>
  270. <tr>
  271. <td valign="top">file</td>
  272. <td valign="top">The file to expose as a file: url</td>
  273. </tr>
  274. <tr>
  275. <td valign="top">baseUrl</td>
  276. <td valign="top">The base URL which must be combined with relativePath</td>
  277. </tr>
  278. <tr>
  279. <td valign="top">relativePath</td>
  280. <td valign="top">Relative path that defines the url combined with
  281. baseUrl</td>
  282. <td align="center" valign="top">If using baseUrl</td>
  283. </tr>
  284. </table>
  285. <h4 id="string">string</h4>
  286. <p>Represents a Java String. It can be written to, but only once, after which
  287. it will be an error to write to again.</p>
  288. <table>
  289. <tr>
  290. <td valign="top"><b>Attribute</b></td>
  291. <td valign="top"><b>Description</b></td>
  292. <td align="center" valign="top"><b>Required</b></td>
  293. </tr>
  294. <tr>
  295. <td valign="top">value</td>
  296. <td valign="top">The value of this resource</td>
  297. <td align="center" valign="top">No</td>
  298. </tr>
  299. </table>
  300. <p>The resource also supports nested text, which can only be supplied if the <code>value</code> attribute is unset:
  301. </p>
  302. <pre>
  303. &lt;string>
  304. self.log("Ant version =${ant.version}");
  305. &lt;/string>
  306. </pre>
  307. <h4 id="propertyresource">propertyresource</h4>
  308. <p>Represents an Ant property.</p>
  309. <table>
  310. <tr>
  311. <td valign="top"><b>Attribute</b></td>
  312. <td valign="top"><b>Description</b></td>
  313. <td align="center" valign="top"><b>Required</b></td>
  314. </tr>
  315. <tr>
  316. <td valign="top">name</td>
  317. <td valign="top">The property name</td>
  318. <td align="center" valign="top">Yes</td>
  319. </tr>
  320. </table>
  321. <hr/>
  322. <h2 id="collection">Resource Collections</h2>
  323. <p>
  324. A Resource Collection is an abstraction of an entity that groups
  325. together a number of <a href="#resource">resources</a>. Several of
  326. Ant's "legacy" datatypes have been modified to behave as Resource Collections:
  327. </p>
  328. <ul>
  329. <li><a href="fileset.html">fileset</a>,
  330. <a href="dirset.html">dirset</a>,
  331. <a href="multirootfileset.html">multirootfileset</a>,
  332. <a href="filelist.html">filelist</a>, and
  333. <a href="../using.html#path">path</a>
  334. (and derivative types) expose <a href="#file">file</a> resources
  335. </li>
  336. <li><a href="tarfileset.html">tarfileset</a>
  337. can expose <a href="#file">file</a> or <a href="#tarentry">tarentry</a>
  338. resources depending on configuration
  339. </li>
  340. <li><a href="zipfileset.html">zipfileset</a>
  341. can expose <a href="#file">file</a> or <a href="#zipentry">zipentry</a>
  342. resources depending on configuration
  343. </li>
  344. <li><a href="propertyset.html">propertyset</a>
  345. exposes <a href="#propertyresource">property</a> resources
  346. </li>
  347. </ul>
  348. <p>Strangely, some tasks can even legitimately behave as resource collections:</p>
  349. <ul>
  350. <li><a href="../Tasks/concat.html">concat</a>
  351. exposes a concatenated resource, and adds e.g.
  352. <a href="filterchain.html">filtering</a>
  353. to Ant's resource-related capabilities.
  354. </li>
  355. </ul>
  356. <h3>The additional built-in resource collections are:</h3>
  357. <ul>
  358. <li><a href="#resources">resources</a> - generic resource collection</li>
  359. <li><a href="#files">files</a> - collection of files similar to
  360. <a href="fileset.html">fileset</a></li>
  361. <li><a href="#restrict">restrict</a> - restrict a resource collection
  362. to include only resources meeting specified criteria</li>
  363. <li><a href="#sort">sort</a> - sorted resource collection</li>
  364. <li><a href="#first">first</a> - first <i>n</i> resources from a
  365. nested collection</li>
  366. <li><a href="#last">last</a> - last <i>n</i> resources from a
  367. nested collection</li>
  368. <li><a href="#allbutfirst">allbutfirst</a> - all except the
  369. first <i>n</i> resources from a nested collection</li>
  370. <li><a href="#allbutlast">allbutlast</a> - all except the last <i>n</i>
  371. resources from a nested collection</li>
  372. <li><a href="#tokens">tokens</a> - <a href="#string">string</a> tokens
  373. gathered from a nested collection</li>
  374. <li><a href="#union">union</a> - set union of nested resource collections</li>
  375. <li><a href="#intersect">intersect</a> - set intersection
  376. of nested resource collections</li>
  377. <li><a href="#difference">difference</a> - set difference
  378. of nested resource collections</li>
  379. <li><a href="#mappedresources">mappedresources</a> - generic
  380. resource collection wrapper that maps the names of the nested
  381. resources using a <a href="mapper.html">mapper</a>.</li>
  382. <li><a href="#archives">archives</a> - wraps around different
  383. resource collections and treats the nested resources as ZIP or TAR
  384. archives that will be extracted on the fly.</li>
  385. <li><a href="#resourcelist">resourcelist</a> - a collection of
  386. resources whose names have been read from another resource.</li>
  387. </ul>
  388. <h4 id="resources">resources</h4>
  389. <p>A generic resource collection, designed for use with
  390. <a href="../using.html#references">references</a>.
  391. For example, if a third-party Ant task generates a Resource Collection
  392. of an unknown type, it can still be accessed via a
  393. <code>&lt;resources&gt;</code> collection. The secondary use of this
  394. collection type is as a container of other resource collections,
  395. preserving the order of nested collections as well as
  396. duplicate resources (contrast with <a href="#union">union</a>).
  397. </p>
  398. <table>
  399. <tr>
  400. <td valign="top"><b>Attribute</b></td>
  401. <td valign="top"><b>Description</b></td>
  402. <td align="center" valign="top"><b>Required</b></td>
  403. </tr>
  404. <tr>
  405. <td valign="top">cache</td>
  406. <td valign="top">Whether to cache results. <em>since Ant 1.8.0</em></td>
  407. <td valign="top" align="center">No, default <i>false</i></td>
  408. </tr>
  409. </table>
  410. <h4 id="files">files</h4>
  411. <p>A group of files. These files are matched by <b>absolute</b> patterns
  412. taken from a number of <a href="patternset.html">PatternSets</a>.
  413. These can be specified as nested <code>&lt;patternset&gt;</code>
  414. elements. In addition, <code>&lt;files&gt;</code> holds an implicit
  415. PatternSet and supports the nested <code>&lt;include&gt;</code>,
  416. <code>&lt;includesfile&gt;</code>, <code>&lt;exclude&gt;</code>
  417. and <code>&lt;excludesfile&gt;</code> elements of PatternSet directly,
  418. as well as PatternSet's attributes.
  419. </p>
  420. <p><a href="selectors.html">File Selectors</a> are available as nested
  421. elements. A file must be selected by all selectors in order to be included;
  422. <code>&lt;files&gt;</code> is thus equivalent to an
  423. <code>&lt;and&gt;</code> file selector container.
  424. </p>
  425. <p><b>More simply put</b>, this type is equivalent to a
  426. <a href="fileset.html">fileset</a> with no base directory.
  427. <b>Please note</b> that without a base directory,
  428. filesystem scanning is based entirely on include and exclude patterns.
  429. A <a href="selectors.html#filenameselect">filename</a> (or any)
  430. selector can <i>only</i> influence the scanning process <i>after</i>
  431. the file has been included based on pattern-based selection.
  432. </p>
  433. <table>
  434. <tr>
  435. <td valign="top"><b>Attribute</b></td>
  436. <td valign="top"><b>Description</b></td>
  437. <td align="center" valign="top"><b>Required</b></td>
  438. </tr>
  439. <tr>
  440. <td valign="top">includes</td>
  441. <td valign="top">comma- or space-separated list of patterns
  442. of files that must be included</td>
  443. <td rowspan="2" valign="middle" align="center">At least one of these</td>
  444. </tr>
  445. <tr>
  446. <td valign="top">includesfile</td>
  447. <td valign="top">the name of a file; each line of this file is
  448. taken to be an include pattern.</td>
  449. </tr>
  450. <tr>
  451. <td valign="top">excludes</td>
  452. <td valign="top">comma- or space-separated list of patterns
  453. of files that must be excluded</td>
  454. <td rowspan="2" valign="top" align="center">No, default none
  455. (except default excludes when true)</td>
  456. </tr>
  457. <tr>
  458. <td valign="top">excludesfile</td>
  459. <td valign="top">the name of a file; each line of this file is
  460. taken to be an exclude pattern.</td>
  461. </tr>
  462. <tr>
  463. <td valign="top">defaultexcludes</td>
  464. <td valign="top">Whether
  465. <a href="../dirtasks.html#defaultexcludes">default excludes</a>
  466. should be used</td>
  467. <td valign="top" align="center">No, default <i>true</i></td>
  468. </tr>
  469. <tr>
  470. <td valign="top">casesensitive</td>
  471. <td valign="top">Whether patterns are case-sensitive</td>
  472. <td valign="top" align="center">No, default <i>true</i></td>
  473. </tr>
  474. <tr>
  475. <td valign="top">followsymlinks</td>
  476. <td valign="top">Whether to follow symbolic links
  477. (see note <a href="#symlink">below</a>)</td>
  478. <td valign="top" align="center">No, default <i>true</i></td>
  479. </tr>
  480. </table>
  481. <p id="symlink"><b>Note</b>: All files/directories for which
  482. the canonical path is different from its path are considered symbolic
  483. links. On Unix systems this usually means the file really is a
  484. symbolic link but it may lead to false results on other
  485. platforms.
  486. </p>
  487. <h4 id="restrict">restrict</h4>
  488. <p>Restricts a nested resource collection using resource selectors:
  489. <table>
  490. <tr>
  491. <td valign="top"><b>Attribute</b></td>
  492. <td valign="top"><b>Description</b></td>
  493. <td align="center" valign="top"><b>Required</b></td>
  494. </tr>
  495. <tr>
  496. <td valign="top">cache</td>
  497. <td valign="top">Whether to cache results; disabling
  498. may seriously impact performance</td>
  499. <td valign="top" align="center">No, default <i>true</i></td>
  500. </tr>
  501. </table>
  502. <h5>Parameters specified as nested elements</h5>
  503. <p>A single resource collection is required.</p>
  504. <p>Nested resource selectors are used to "narrow down" the included
  505. resources, combined via a logical <i>AND</i>. These are patterned
  506. after <a href="selectors.html">file selectors</a> but are,
  507. unsurprisingly, targeted to resources.
  508. Several built-in resource selectors are available in the internal
  509. <a href="antlib.html">antlib</a>
  510. <code>org.apache.tools.ant.types.resources.selectors</code>:
  511. </p>
  512. <ul>
  513. <li><a href="#rsel.name">name</a> - select resources by name.</li>
  514. <li><a href="#rsel.exists">exists</a> - select existing resources.</li>
  515. <li><a href="#rsel.date">date</a> - select resources by date.</li>
  516. <li><a href="#rsel.type">type</a> - select resources by type.</li>
  517. <li><a href="#rsel.size">size</a> - select resources by size.</li>
  518. <li><a href="#rsel.instanceof">instanceof</a>
  519. - select resources by class or Ant datatype.</li>
  520. <li><a href="#rsel.and">and</a> - "and" nested resource selectors.</li>
  521. <li><a href="#rsel.or">or</a> - "or" nested resource selectors.</li>
  522. <li><a href="#rsel.not">not</a> - "not" a nested resource selector.</li>
  523. <li><a href="#rsel.none">none</a>
  524. - select resources selected by no nested resource selectors.</li>
  525. <li><a href="#rsel.majority">majority</a> - select resources selected
  526. by a majority of nested resource selectors.</li>
  527. <li><a href="selectors.html#modified">modified</a> - select resources which
  528. content has changed.</li>
  529. <li><a href="selectors.html#containsselect">contains</a> - select resources
  530. containing a particular text string.</li>
  531. <li><a href="selectors.html#regexpselect">containsregexp</a> - select
  532. resources whose contents match a particular regular expression.</li>
  533. <li><a href="#rsel.compare">compare</a> - select resources
  534. based on comparison to other resources.</li>
  535. <li><a href="selectors.html#readable">readable</a> -
  536. Select files (resources must be files) if they are readable.</li>
  537. <li><a href="selectors.html#writable">writable</a> -
  538. Select files (resources must be files) if they are writable.</li>
  539. </ul>
  540. <h5 id="rsel.name">name</h5>
  541. <p>Selects resources by name.</p>
  542. <table>
  543. <tr>
  544. <td valign="top"><b>Attribute</b></td>
  545. <td valign="top"><b>Description</b></td>
  546. <td align="center" valign="top"><b>Required</b></td>
  547. </tr>
  548. <tr>
  549. <td valign="top">name</td>
  550. <td valign="top">The name pattern to test using standard Ant
  551. patterns.</td>
  552. <td valign="top" align="center" rowspan="2">Exactly one of
  553. the two</td>
  554. </tr>
  555. <tr>
  556. <td valign="top">regex</td>
  557. <td valign="top">The regular expression matching files to select.</td>
  558. </tr>
  559. <tr>
  560. <td valign="top">casesensitive</td>
  561. <td valign="top">Whether name comparisons are case-sensitive</td>
  562. <td align="center" valign="top">No, default <i>true</i></td>
  563. </tr>
  564. <tr>
  565. <td valign="top">handledirsep</td>
  566. <td valign="top">
  567. If this is specified, the mapper will treat a \ character in a
  568. resource name or name attribute as a / for the purposes of
  569. matching. This attribute can be true or false, the default is
  570. false.
  571. <em>Since Ant 1.8.0</em>
  572. <td align="center" valign="top">No</td>
  573. </tr>
  574. </table>
  575. <h5 id="rsel.exists">exists</h5>
  576. <p>Selects existing resources.</p>
  577. <h5 id="rsel.date">date</h5>
  578. <p>Selects resources by date.</p>
  579. <table>
  580. <tr>
  581. <td valign="top"><b>Attribute</b></td>
  582. <td valign="top"><b>Description</b></td>
  583. <td align="center" valign="top"><b>Required</b></td>
  584. </tr>
  585. <tr>
  586. <td valign="top">millis</td>
  587. <td valign="top">The comparison date/time in ms since January 1, 1970</td>
  588. <td rowspan="2" align="center" valign="middle">One of these</td>
  589. </tr>
  590. <tr>
  591. <td valign="top">datetime</td>
  592. <td valign="top">The formatted comparison date/time</td>
  593. </tr>
  594. <tr>
  595. <td valign="top">pattern</td>
  596. <td valign="top">SimpleDateFormat-compatible pattern
  597. for use with the <code>datetime</code> attribute using the
  598. current locale</td>
  599. <td align="center" valign="top">
  600. No, default is "MM/dd/yyyy hh:mm a" using the US locale</td>
  601. </tr>
  602. <tr>
  603. <td valign="top">granularity</td>
  604. <td valign="top">The number of milliseconds leeway to use when
  605. comparing file modification times. This is needed because not
  606. every file system supports tracking the last modified time to
  607. the millisecond level.</td>
  608. <td align="center" valign="top">No; default varies by platform:
  609. FAT filesystems = 2 sec; Unix = 1 sec; NTFS = 1 ms.</td>
  610. </tr>
  611. <tr>
  612. <td valign="top">when</td>
  613. <td valign="top">One of "before", "after", "equal"</td>
  614. <td align="center" valign="top">No, default "equal"</td>
  615. </tr>
  616. </table>
  617. <h5 id="rsel.type">type</h5>
  618. <p>Selects resources by type (file or directory).</p>
  619. <table>
  620. <tr>
  621. <td valign="top"><b>Attribute</b></td>
  622. <td valign="top"><b>Description</b></td>
  623. <td align="center" valign="top"><b>Required</b></td>
  624. </tr>
  625. <tr>
  626. <td valign="top">type</td>
  627. <td valign="top">One of "file", "dir", "any" (<em>since Ant 1.8</em>)</td>
  628. <td align="center" valign="top">Yes</td>
  629. </tr>
  630. </table>
  631. <h5 id="rsel.size">size</h5>
  632. <p>Selects resources by size.</p>
  633. <table>
  634. <tr>
  635. <td valign="top"><b>Attribute</b></td>
  636. <td valign="top"><b>Description</b></td>
  637. <td align="center" valign="top"><b>Required</b></td>
  638. </tr>
  639. <tr>
  640. <td valign="top">size</td>
  641. <td valign="top">The size to compare</td>
  642. <td align="center" valign="top">Yes</td>
  643. </tr>
  644. <tr>
  645. <td valign="top">when</td>
  646. <td valign="top">One of "equal", "eq", "greater", "gt", "less", "lt",
  647. "ge" (greater or equal), "ne" (not equal), "le" (less or equal)</td>
  648. <td align="center" valign="top">No, default "equal"</td>
  649. </tr>
  650. </table>
  651. <h5 id="rsel.instanceof">instanceof</h5>
  652. <p>Selects resources by type.</p>
  653. <table>
  654. <tr>
  655. <td valign="top"><b>Attribute</b></td>
  656. <td valign="top"><b>Description</b></td>
  657. <td align="center" valign="top"><b>Required</b></td>
  658. </tr>
  659. <tr>
  660. <td valign="top">class</td>
  661. <td valign="top">The class of which the resource must be an instance</td>
  662. <td rowspan="2" align="center" valign="middle">One of these</td>
  663. </tr>
  664. <tr>
  665. <td valign="top">type</td>
  666. <td valign="top">The Ant type that must
  667. be assignable from the resource</td>
  668. </tr>
  669. <tr>
  670. <td valign="top">uri</td>
  671. <td valign="top">The uri in which <i>type</i> must be defined</td>
  672. <td valign="top">No</td>
  673. </tr>
  674. </table>
  675. <h5 id="rsel.and">and</h5>
  676. <p>Selects a resource if it is selected by all nested resource selectors.</p>
  677. <h5 id="rsel.or">or</h5>
  678. <p>Selects a resource if it is selected
  679. by at least one nested resource selector.</p>
  680. <h5 id="rsel.not">not</h5>
  681. <p>Negates the selection result of the single
  682. nested resource selector allowed.</p>
  683. <h5 id="rsel.none">none</h5>
  684. <p>Selects a resource if it is selected
  685. by no nested resource selectors.</p>
  686. <h5 id="rsel.majority">majority</h5>
  687. <p>Selects a resource if it is selected
  688. by the majority of nested resource selectors.</p>
  689. <table>
  690. <tr>
  691. <td valign="top"><b>Attribute</b></td>
  692. <td valign="top"><b>Description</b></td>
  693. <td align="center" valign="top"><b>Required</b></td>
  694. </tr>
  695. <tr>
  696. <td valign="top">allowtie</td>
  697. <td valign="top">Whether a tie (when there is an even number
  698. of nested resource selectors) is considered a majority</td>
  699. <td valign="top">No, default <i>true</i></td>
  700. </tr>
  701. </table>
  702. <h5 id="rsel.compare">compare</h5>
  703. <p>Selects a resource based on its comparison to one or more "control"
  704. resources using nested <a href="#rcmp">resource comparators</a>.</p>
  705. <table>
  706. <tr>
  707. <td valign="top"><b>Attribute</b></td>
  708. <td valign="top"><b>Description</b></td>
  709. <td align="center" valign="top"><b>Required</b></td>
  710. </tr>
  711. <tr>
  712. <td valign="top">when</td>
  713. <td valign="top">Comparison ("equal"/"eq", "greater"/"gt", "less"/"lt",
  714. "le" (less or equal), "ge" (greater or equal), "ne" (not equal).</td>
  715. <td valign="top">No, default "equal"</td>
  716. </tr>
  717. <tr>
  718. <td valign="top">against</td>
  719. <td valign="top">Quantifier ("all"/"each"/"every", "any"/"some",
  720. (exactly) "one", "most"/"majority", "none".</td>
  721. <td valign="top">No, default "all"</td>
  722. </tr>
  723. </table>
  724. <h6>Parameters specified as nested elements</h6>
  725. <p>The resources against which comparisons will be made must be specified
  726. using the nested &lt;control&gt; element, which denotes a
  727. <a href="#resources">resources</a> collection.</p>
  728. <h6>Examples</h6>
  729. <p>Assuming the namespace settings</p>
  730. <pre> rsel="antlib:org.apache.tools.ant.types.resources.selectors"
  731. rcmp="antlib:org.apache.tools.ant.types.resources.comparators"
  732. </pre>
  733. <pre>
  734. &lt;restrict&gt;
  735. &lt;fileset dir="src" includes="a,b,c,d,e,f,g" /&gt;
  736. &lt;rsel:compare when="le" against="all"&gt;
  737. &lt;control&gt;
  738. &lt;resource name="d" /&gt;
  739. &lt;/control&gt;
  740. &lt;rcmp:name /&gt;
  741. &lt;/rsel:compare&gt;
  742. &lt;/restrict&gt;
  743. </pre>
  744. <p>Selects files a, b, c, and d.</p>
  745. <pre>
  746. &lt;project rsel=&quot;antlib:org.apache.tools.ant.types.resources.selectors&quot;&gt;
  747. &lt;macrodef name=&quot;copyFromPath&quot;&gt;
  748. &lt;attribute name=&quot;todir&quot;/&gt;
  749. &lt;attribute name=&quot;refid&quot;/&gt;
  750. &lt;element name=&quot;nested-resource-selectors&quot; optional=&quot;yes&quot; implicit=&quot;true&quot;/&gt;
  751. &lt;sequential&gt;
  752. &lt;mkdir dir=&quot;@{todir}&quot; taskname=&quot;copyFromPath&quot;/&gt;
  753. &lt;copy todir=&quot;@{todir}&quot; taskname=&quot;copyFromPath&quot;&gt;
  754. &lt;restrict&gt;
  755. &lt;path refid=&quot;@{refid}&quot;/&gt;
  756. &lt;rsel:or&gt;
  757. &lt;nested-resource-selectors/&gt;
  758. &lt;/rsel:or&gt;
  759. &lt;/restrict&gt;
  760. &lt;flattenmapper/&gt;
  761. &lt;/copy&gt;
  762. &lt;/sequential&gt;
  763. &lt;/macrodef&gt;
  764. &lt;copyFromPath refid=&quot;classpath&quot; todir=&quot;todir&quot;&gt;
  765. &lt;rsel:name name=&quot;log4j.properties&quot;/&gt;
  766. &lt;rsel:name name=&quot;default.properties&quot;/&gt;
  767. &lt;/copyFromPath&gt;
  768. &lt;/project&gt;
  769. </pre>
  770. <p>Creates the <tt>todir</tt> directory and copies (if present) the
  771. files <tt>log4j.properties</tt> and <tt>default.properties</tt>
  772. from the Classpath (already used while compiling).
  773. </p>
  774. <pre>
  775. &lt;project&gt;
  776. &lt;filelist id=&quot;allfiles&quot; dir=&quot;${ant.home}/bin&quot; files=&quot;ant.cmd,foo.txt,ant.bat,bar.txt,ant&quot;/&gt;
  777. &lt;restrict id=&quot;missingfiles&quot;&gt;
  778. &lt;filelist refid=&quot;allfiles&quot;/&gt;
  779. &lt;rsel:not xmlns:rsel=&quot;antlib:org.apache.tools.ant.types.resources.selectors&quot;&gt;
  780. &lt;rsel:exists/&gt;
  781. &lt;/rsel:not&gt;
  782. &lt;/restrict&gt;
  783. &lt;echo&gt;These files are missed: ${toString:missingfiles}&lt;/echo&gt;
  784. &lt;/project&gt;
  785. </pre>
  786. <p>The resource collection <i>allfiles</i> defines a list of files which are expected. The restrict
  787. <i>missingfiles</i> uses the <tt>&lt;not&gt;&lt;exists&gt;</tt> selector for getting all files
  788. which are not present. Finally we use the <i>toString:</i> <a href="../using.html#pathshortcut">pathshortcut</a> for
  789. getting them in a readable form: <tt>[echo] These files are missed: ....foo.txt;....bar.txt</tt></p>
  790. <h4 id="sort">sort</h4>
  791. <p>Sorts a nested resource collection according to the resources'
  792. natural order, or by one or more nested <a href="#rcmp">resource
  793. comparators</a>:</p>
  794. <table>
  795. <tr>
  796. <td valign="top"><b>Attribute</b></td>
  797. <td valign="top"><b>Description</b></td>
  798. <td align="center" valign="top"><b>Required</b></td>
  799. </tr>
  800. <tr>
  801. <td valign="top">cache</td>
  802. <td valign="top">Whether to cache results; disabling
  803. may seriously impact performance</td>
  804. <td valign="top" align="center">No, default <i>true</i></td>
  805. </tr>
  806. </table>
  807. <h5>Parameters specified as nested elements</h5>
  808. <p>A single resource collection is required.</p>
  809. <p>The sort can be controlled and customized by specifying one or more
  810. resource comparators. Resources can be sorted according to multiple
  811. criteria; the first specified is the "outermost", while the last
  812. specified is the "innermost". Several built-in resource comparators
  813. are available in the internal <a href="antlib.html">antlib</a>
  814. <code>org.apache.tools.ant.types.resources.comparators</code>:
  815. </p>
  816. <h5 id="rcmp">Resource Comparators:</h5>
  817. <ul>
  818. <li><a href="#rcmp.name">name</a> - sort resources by name</li>
  819. <li><a href="#rcmp.exists">exists</a> - sort resources by existence</li>
  820. <li><a href="#rcmp.date">date</a> - sort resources by date</li>
  821. <li><a href="#rcmp.type">type</a> - sort resources by type</li>
  822. <li><a href="#rcmp.size">size</a> - sort resources by size</li>
  823. <li><a href="#rcmp.content">content</a> - sort resources by content</li>
  824. <li><a href="#rcmp.reverse">reverse</a> - reverse the natural sort order,
  825. or that of a single nested resource comparator</li>
  826. </ul>
  827. <h6 id="rcmp.name">name</h6>
  828. <p>Sort resources by name.</p>
  829. <h6 id="rcmp.exists">exists</h6>
  830. <p>Sort resources by existence.
  831. Not existing is considered "less than" existing.</p>
  832. <h6 id="rcmp.date">date</h6>
  833. <p>Sort resources by date.</p>
  834. <h6 id="rcmp.type">type</h6>
  835. <p>Sort resources by type (file or directory).
  836. Because directories contain files, they are considered "greater".</p>
  837. <h6 id="rcmp.size">size</h6>
  838. <p>Sort resources by size.</p>
  839. <h6 id="rcmp.content">content</h6>
  840. <p>Sort resources by content.</p>
  841. <table>
  842. <tr>
  843. <td valign="top"><b>Attribute</b></td>
  844. <td valign="top"><b>Description</b></td>
  845. <td align="center" valign="top"><b>Required</b></td>
  846. </tr>
  847. <tr>
  848. <td valign="top">binary</td>
  849. <td valign="top">Whether content should be compared in binary mode.
  850. If <i>false</i>, content will be compared without regard to
  851. platform-specific line-ending conventions.</td>
  852. <td valign="top">No, default <i>true</i></td>
  853. </tr>
  854. </table>
  855. <h6 id="rcmp.reverse">reverse</h6>
  856. <p>Reverse the natural sort order, or that of a single nested comparator.</p>
  857. <h5>Examples</h5>
  858. <pre>
  859. &lt;property name=&quot;eol&quot; value=&quot;${line.separator}&quot; /&gt;
  860. &lt;pathconvert property=&quot;sorted&quot; pathsep=&quot;${eol}&quot;&gt;
  861. &lt;sort&gt;
  862. &lt;tokens&gt;
  863. &lt;string value=&quot;foo bar etc baz&quot; /&gt;
  864. &lt;stringtokenizer /&gt;
  865. &lt;/tokens&gt;
  866. &lt;/sort&gt;
  867. &lt;/pathconvert&gt;</pre>
  868. <p>The resource of type string &quot;foo bar etc baz&quot; is split into four tokens by
  869. the stringtokenizer. These tokens are sorted and there <i>sorted</i> gets the value
  870. of &quot;bar baz etc foo&quot;.</p>
  871. <pre>
  872. &lt;sort&gt;
  873. &lt;fileset dir=&quot;foo&quot; /&gt;
  874. &lt;reverse xmlns=&quot;antlib:org.apache.tools.ant.types.resources.comparators&quot;&gt;
  875. &lt;date /&gt;
  876. &lt;/reverse&gt;
  877. &lt;/sort&gt;</pre>
  878. <p>This takes all files from <i>foo</i>
  879. and sorts them by modification date in reverse order.
  880. Because the resource comparators used (<code>&lt;reverse&gt;</code>
  881. and <code>&lt;date&gt;</code>) are in an internal antlib
  882. their namespace must be set explicitly.
  883. </p>
  884. <h4 id="first">first</h4>
  885. <p>Includes the first <i>count</i> resources from a nested resource collection.
  886. This can be used in conjunction with the <a href="#sort">sort</a> collection,
  887. for example, to select the first few oldest, largest, etc. resources from a
  888. larger collection.</p>
  889. <table>
  890. <tr>
  891. <td valign="top"><b>Attribute</b></td>
  892. <td valign="top"><b>Description</b></td>
  893. <td align="center" valign="top"><b>Required</b></td>
  894. </tr>
  895. <tr>
  896. <td valign="top">count</td>
  897. <td valign="top">The number of resources to include</td>
  898. <td valign="top" align="center">No, default 1</td>
  899. </tr>
  900. <tr>
  901. <td valign="top">cache</td>
  902. <td valign="top">Whether to cache results; disabling
  903. may seriously impact performance</td>
  904. <td valign="top" align="center">No, default <i>true</i></td>
  905. </tr>
  906. </table>
  907. <h5>Parameters specified as nested elements</h5>
  908. <p>A single resource collection is required.</p>
  909. <h4 id="last">last</h4>
  910. <p>Includes the last <i>count</i> resources from a nested resource collection.
  911. This can be used in conjunction with the <a href="#sort">sort</a> collection,
  912. for example, to select the last few oldest, largest, etc. resources from a
  913. larger collection. <em>Since Ant 1.7.1</em></p>
  914. <table>
  915. <tr>
  916. <td valign="top"><b>Attribute</b></td>
  917. <td valign="top"><b>Description</b></td>
  918. <td align="center" valign="top"><b>Required</b></td>
  919. </tr>
  920. <tr>
  921. <td valign="top">count</td>
  922. <td valign="top">The number of resources to include</td>
  923. <td valign="top" align="center">No, default 1</td>
  924. </tr>
  925. <tr>
  926. <td valign="top">cache</td>
  927. <td valign="top">Whether to cache results; disabling
  928. may seriously impact performance</td>
  929. <td valign="top" align="center">No, default <i>true</i></td>
  930. </tr>
  931. </table>
  932. <h5>Parameters specified as nested elements</h5>
  933. <p>A single resource collection is required.</p>
  934. <h4 id="allbutfirst">allbutfirst</h4>
  935. <p>Includes all elements except for the first <i>count</i> resources
  936. from a nested resource collection. This can be used in conjunction
  937. with the <a href="#sort">sort</a> collection, for example, to select
  938. all but the first few oldest, largest, etc. resources from a larger
  939. collection. <em>Since Ant 1.9.5</em></p>
  940. <table>
  941. <tr>
  942. <td valign="top"><b>Attribute</b></td>
  943. <td valign="top"><b>Description</b></td>
  944. <td align="center" valign="top"><b>Required</b></td>
  945. </tr>
  946. <tr>
  947. <td valign="top">count</td>
  948. <td valign="top">The number of resources to exclude</td>
  949. <td valign="top" align="center">No, default 1</td>
  950. </tr>
  951. <tr>
  952. <td valign="top">cache</td>
  953. <td valign="top">Whether to cache results; disabling
  954. may seriously impact performance</td>
  955. <td valign="top" align="center">No, default <i>true</i></td>
  956. </tr>
  957. </table>
  958. <h5>Parameters specified as nested elements</h5>
  959. <p>A single resource collection is required.</p>
  960. <h4 id="allbutlast">allbutlast</h4>
  961. <p>Includes all elements except for the last <i>count</i> resources
  962. from a nested resource collection. This can be used in conjunction
  963. with the <a href="#sort">sort</a> collection, for example, to select
  964. all but the last few oldest, largest, etc. resources from a larger
  965. collection. <em>Since Ant 1.9.5</em></p>
  966. <table>
  967. <tr>
  968. <td valign="top"><b>Attribute</b></td>
  969. <td valign="top"><b>Description</b></td>
  970. <td align="center" valign="top"><b>Required</b></td>
  971. </tr>
  972. <tr>
  973. <td valign="top">count</td>
  974. <td valign="top">The number of resources to exclude</td>
  975. <td valign="top" align="center">No, default 1</td>
  976. </tr>
  977. <tr>
  978. <td valign="top">cache</td>
  979. <td valign="top">Whether to cache results; disabling
  980. may seriously impact performance</td>
  981. <td valign="top" align="center">No, default <i>true</i></td>
  982. </tr>
  983. </table>
  984. <h5>Parameters specified as nested elements</h5>
  985. <p>A single resource collection is required.</p>
  986. <h4 id="tokens">tokens</h4>
  987. <p>Includes the <a href="#string">string</a> tokens gathered from a nested
  988. resource collection. Uses the same tokenizers supported by the
  989. <a href="filterchain.html#tokenfilter">TokenFilter</a>. Imaginative
  990. use of this resource collection can implement equivalents for such Unix
  991. functions as <code>sort</code>, <code>grep -c</code>, <code>wc</code> and
  992. <code>wc -l</code>.</p>
  993. <table>
  994. <tr>
  995. <td valign="top"><b>Attribute</b></td>
  996. <td valign="top"><b>Description</b></td>
  997. <td align="center" valign="top"><b>Required</b></td>
  998. </tr>
  999. <tr>
  1000. <td valign="top">encoding</td>
  1001. <td valign="top">The encoding of the nested resources</td>
  1002. <td valign="top" align="center">No, default is platform default</td>
  1003. </tr>
  1004. <tr>
  1005. <td valign="top">cache</td>
  1006. <td valign="top">Whether to cache results; disabling
  1007. may seriously impact performance</td>
  1008. <td valign="top" align="center">No, default <i>true</i></td>
  1009. </tr>
  1010. </table>
  1011. <h5>Parameters specified as nested elements</h5>
  1012. <ul>
  1013. <li>A single resource collection is required.</li>
  1014. <li>One nested tokenizer may be specified. If omitted, a
  1015. <a href="filterchain.html#linetokenizer">LineTokenizer</a> will be used.
  1016. </li>
  1017. </ul>
  1018. <h5>Examples</h5>
  1019. <pre>&lt;concat&gt;
  1020. &lt;union&gt;
  1021. &lt;sort&gt;
  1022. &lt;tokens&gt;
  1023. &lt;resources refid="input" /&gt;
  1024. &lt;linetokenizer includedelims="true" /&gt;
  1025. &lt;/tokens&gt;
  1026. &lt;/sort&gt;
  1027. &lt;/union&gt;
  1028. &lt;/concat&gt;
  1029. </pre>
  1030. <p>Implements Unix <i>sort -u</i> against resource collection <i>input</i>.</p>
  1031. <h4 id="setlogic">Set operations</h4>
  1032. <p>The following resource collections implement set operations:</p>
  1033. <ul>
  1034. <li><a href="#union">union</a></li>
  1035. <li><a href="#intersect">intersect</a></li>
  1036. <li><a href="#difference">difference</a></li>
  1037. </ul>
  1038. <h4 id="union">union</h4>
  1039. <p>Union of nested resource collections.</p>
  1040. <h4 id="intersect">intersect</h4>
  1041. <p>Intersection of nested resource collections.</p>
  1042. <h4 id="difference">difference</h4>
  1043. <p>Difference of nested resource collections.</p>
  1044. <p>The following attributes apply to all set-operation resource collections:
  1045. </p>
  1046. <table>
  1047. <tr>
  1048. <td valign="top"><b>Attribute</b></td>
  1049. <td valign="top"><b>Description</b></td>
  1050. <td align="center" valign="top"><b>Required</b></td>
  1051. </tr>
  1052. <tr>
  1053. <td valign="top">cache</td>
  1054. <td valign="top">Whether to cache results; disabling
  1055. may seriously impact performance</td>
  1056. <td valign="top" align="center">No, default <i>true</i></td>
  1057. </tr>
  1058. </table>
  1059. <h5>Examples</h5>
  1060. <pre>
  1061. &lt;resources id=&quot;A&quot;&gt;
  1062. &lt;string value=&quot;a&quot;/&gt;
  1063. &lt;string value=&quot;b&quot;/&gt;
  1064. &lt;/resources&gt;
  1065. &lt;resources id=&quot;B&quot;&gt;
  1066. &lt;string value=&quot;b&quot;/&gt;
  1067. &lt;string value=&quot;c&quot;/&gt;
  1068. &lt;/resources&gt;
  1069. &lt;union id=&quot;union&quot;&gt;&lt;resources refid=&quot;A&quot;/&gt;&lt;resources refid=&quot;B&quot;/&gt;&lt;/union&gt;
  1070. &lt;intersect id=&quot;intersect&quot;&gt;&lt;resources refid=&quot;A&quot;/&gt;&lt;resources refid=&quot;B&quot;/&gt;&lt;/intersect&gt;
  1071. &lt;difference id=&quot;difference&quot;&gt;&lt;resources refid=&quot;A&quot;/&gt;&lt;resources refid=&quot;B&quot;/&gt;&lt;/difference&gt;
  1072. &lt;echo&gt;
  1073. A: ${toString:A} = a;b
  1074. B: ${toString:B} = b;c
  1075. union : ${toString:union} = a;b;c
  1076. intersect : ${toString:intersect} = b
  1077. difference: ${toString:difference} = a;c
  1078. &lt;/echo&gt;
  1079. </pre>
  1080. <h4 id="mappedresources">mappedresources</h4>
  1081. <p><em>Since Ant 1.8.0</em></p>
  1082. <p>Wraps another resource collection and maps the names of the nested
  1083. resources using a <a href="mapper.html">mapper</a>.</p>
  1084. <p>Even if <em>mappedresources</em> wraps a resource collection that
  1085. consists of file-system based resources, <em>mappedresources</em>
  1086. will not appear to be file-system based. This means you can't
  1087. use <em>mappedresources</em> with tasks that only allow file-system
  1088. based resources.</p>
  1089. <h5>Parameters specified as attributes</h5>
  1090. <table>
  1091. <tr>
  1092. <td valign="top"><b>Attribute</b></td>
  1093. <td valign="top"><b>Description</b></td>
  1094. <td align="center" valign="top"><b>Required</b></td>
  1095. </tr>
  1096. <tr>
  1097. <td valign="top">cache</td>
  1098. <td valign="top">Whether to cache results; enabling
  1099. may improve performance. <em>Since Ant 1.8.1</em></td>
  1100. <td valign="top" align="center">No, default <i>false</i></td>
  1101. </tr>
  1102. <tr>
  1103. <td valign="top">enablemultiplemappings</td>
  1104. <td valign="top">
  1105. If true the the collection will use all the mappings for a
  1106. given source path. If false the it will only process the first
  1107. resource.
  1108. <em>since Ant 1.8.1</em></td>
  1109. <td align="center">No - defaults to false.</td>
  1110. </tr>
  1111. </table>
  1112. <h5>Parameters specified as nested elements</h5>
  1113. <p>A single resource collection is required.</p>
  1114. <p>A single <a href="mapper.html">mapper</a> can be used to map
  1115. names. If no mapper has been given (which doesn't make any sense,
  1116. honestly), an identity mapper will be used.</p>
  1117. <h5>Examples</h5>
  1118. <p>Copies all files from a given directory to a target directory
  1119. adding ".bak" as an extension. Note this could be done with a
  1120. <em>mapper</em> nested into <em>copy</em> directly as well.</p>
  1121. <pre>
  1122. &lt;copy todir="${target}"&gt;
  1123. &lt;mappedresources&gt;
  1124. &lt;fileset dir="${src}"/&gt;
  1125. &lt;globmapper from="*" to="*.bak"/&gt;
  1126. &lt;/mappedresources&gt;
  1127. &lt;/copy&gt;
  1128. </pre>
  1129. <p>Creates a WAR archive adding all CLASSPATH entries that are files
  1130. to the <code>WEB-INF/lib</code> directory without keeping their
  1131. files-system structure.</p>
  1132. <pre>
  1133. &lt;war destfile="${output}"&gt;
  1134. &lt;mappedresources&gt;
  1135. &lt;restrict&gt;
  1136. &lt;path path="${java.class.path}"/&gt;
  1137. &lt;type type="file"/&gt;
  1138. &lt;/restrict&gt;
  1139. &lt;chainedmapper&gt;
  1140. &lt;flattenmapper/&gt;
  1141. &lt;globmapper from="*" to="WEB-INF/lib/*"/&gt;
  1142. &lt;/chainedmapper&gt;
  1143. &lt;/mappedresources&gt;
  1144. &lt;/war&gt;
  1145. </pre>
  1146. <h4 id="archives">archives</h4>
  1147. <p><em>Since Ant 1.8.0</em></p>
  1148. <p>This resource collection accepts an arbitrary number of nested
  1149. resources and assumes that all those resources must be either ZIP or
  1150. TAR archives. The resources returned
  1151. by <code>&lt;archives&gt;</code> are the contents of the nested
  1152. archives.</p>
  1153. <p>This resource collection is a generalization
  1154. of <a href="../Tasks/zip.html#zipgroupfileset">zipgroupfileset</a>
  1155. which is only supported by the zip family of tasks.</p>
  1156. <p><em>archives</em> doesn't support any attributes.</p>
  1157. <h5>Parameters specified as nested elements</h5>
  1158. <p><code>&lt;archives&gt;</code> has two nested
  1159. elements <code>&lt;zips&gt;</code> and
  1160. <code>&lt;tars&gt;</code> that are <a href="#union">unions</a>
  1161. themselves, i.e. they accept arbitrary many resource(collection)s
  1162. as nested elements.</p>
  1163. <p>The nested resources of &lt;zips&gt; are treated as ZIP archives,
  1164. the nested resources of &lt;tars&gt; as TAR archives.</p>
  1165. <h5>Examples</h5>
  1166. <p>Copies all files from all jars that are on the classpath
  1167. to <code>${target}</code>.</p>
  1168. <pre>
  1169. &lt;copy todir="${target}"&gt;
  1170. &lt;archives&gt;
  1171. &lt;zips&gt;
  1172. &lt;restrict&gt;
  1173. &lt;path path="${java.class.path}"/&gt;
  1174. &lt;name name="*.jar"/&gt;
  1175. &lt;/restrict&gt;
  1176. &lt;/zips&gt;
  1177. &lt;/archives&gt;
  1178. &lt;/copy&gt;
  1179. </pre>
  1180. <h4 id="resourcelist">resourcelist</h4>
  1181. <p><em>Since Ant 1.8.0</em></p>
  1182. <p>This resource collection accepts an arbitrary number of nested
  1183. resources, reads those resources and returns a resource for each
  1184. line read.</p>
  1185. <p>If the line contains a colon, Ant will try to use it as an URL and
  1186. if that fails (or the line doesn't contain a colon) will return a
  1187. file resource with the line's content as its name.</p>
  1188. <p>Properties will be expanded for each line. If the property
  1189. expansion yields a resource object rather than a string (for example
  1190. because of custom property helpers), the resources will be returned
  1191. directly.</p>
  1192. <p><code>&lt;resourcelist&gt;</code> is a generalization
  1193. of <a href="filelist.html"><code>&lt;filelist&gt;</code></a>.</p>
  1194. <table>
  1195. <tr>
  1196. <td valign="top"><b>Attribute</b></td>
  1197. <td valign="top"><b>Description</b></td>
  1198. <td align="center" valign="top"><b>Required</b></td>
  1199. </tr>
  1200. <tr>
  1201. <td valign="top">encoding</td>
  1202. <td valign="top">The encoding of the nested resources</td>
  1203. <td valign="top" align="center">No, default is platform default</td>
  1204. </tr>
  1205. </table>
  1206. <h5>Parameters specified as nested elements</h5>
  1207. <p><code>&lt;resourcelist&gt;</code> accepts arbitrary many
  1208. resource(collection)s as nested elements.</p>
  1209. <p>In addition <code>&lt;resourcelist&gt;</code> supports
  1210. nested <code>&lt;filterchain&gt;</code> elements that can be used
  1211. to filter/modify the read resources before their lines get
  1212. expanded. Such a nested element corresponds to
  1213. a <a href="filterchain.html">filterchain</a>.</p>
  1214. <h5>Examples</h5>
  1215. <p>The following example copies a file from the first URL of
  1216. several alternatives that can actually be reached. It assumes
  1217. that the file mirrors.txt looks like</p>
  1218. <pre>
  1219. mirrors.txt:
  1220. http://best.mirror.example.org/
  1221. http://second.best.mirror.example.org/mirror/of/best/
  1222. https://yet.another.mirror/
  1223. http://the.original.site/
  1224. </pre>
  1225. <pre>
  1226. &lt;copy todir="${target}"&gt;
  1227. &lt;first&gt;
  1228. &lt;restrict&gt;
  1229. &lt;resourcelist&gt;
  1230. &lt;file file="mirrors.txt"/&gt;
  1231. &lt;/resourcelist&gt;
  1232. &lt;exists/&gt;
  1233. &lt;/restrict&gt;
  1234. &lt;/first&gt;
  1235. &lt;/copy&gt;
  1236. </pre>
  1237. </body>
  1238. </html>