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

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