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 50 kB

10 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364
  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><code>&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. </code></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><code>&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;</code></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. <blockquote>
  399. <table>
  400. <tr>
  401. <td valign="top"><b>Attribute</b></td>
  402. <td valign="top"><b>Description</b></td>
  403. <td align="center" valign="top"><b>Required</b></td>
  404. </tr>
  405. <tr>
  406. <td valign="top">cache</td>
  407. <td valign="top">Whether to cache results. <em>since Ant 1.8.0</em></td>
  408. <td valign="top" align="center">No, default <i>false</i></td>
  409. </tr>
  410. </table>
  411. </blockquote>
  412. <h4 id="files">files</h4>
  413. <p>A group of files. These files are matched by <b>absolute</b> patterns
  414. taken from a number of <a href="patternset.html">PatternSets</a>.
  415. These can be specified as nested <code>&lt;patternset&gt;</code>
  416. elements. In addition, <code>&lt;files&gt;</code> holds an implicit
  417. PatternSet and supports the nested <code>&lt;include&gt;</code>,
  418. <code>&lt;includesfile&gt;</code>, <code>&lt;exclude&gt;</code>
  419. and <code>&lt;excludesfile&gt;</code> elements of PatternSet directly,
  420. as well as PatternSet's attributes.
  421. </p>
  422. <p><a href="selectors.html">File Selectors</a> are available as nested
  423. elements. A file must be selected by all selectors in order to be included;
  424. <code>&lt;files&gt;</code> is thus equivalent to an
  425. <code>&lt;and&gt;</code> file selector container.
  426. </p>
  427. <p><b>More simply put</b>, this type is equivalent to a
  428. <a href="fileset.html">fileset</a> with no base directory.
  429. <b>Please note</b> that without a base directory,
  430. filesystem scanning is based entirely on include and exclude patterns.
  431. A <a href="selectors.html#filenameselect">filename</a> (or any)
  432. selector can <i>only</i> influence the scanning process <i>after</i>
  433. the file has been included based on pattern-based selection.
  434. </p>
  435. <table>
  436. <tr>
  437. <td valign="top"><b>Attribute</b></td>
  438. <td valign="top"><b>Description</b></td>
  439. <td align="center" valign="top"><b>Required</b></td>
  440. </tr>
  441. <tr>
  442. <td valign="top">includes</td>
  443. <td valign="top">comma- or space-separated list of patterns
  444. of files that must be included</td>
  445. <td rowspan="2" valign="middle" align="center">At least one of these</td>
  446. </tr>
  447. <tr>
  448. <td valign="top">includesfile</td>
  449. <td valign="top">the name of a file; each line of this file is
  450. taken to be an include pattern.</td>
  451. </tr>
  452. <tr>
  453. <td valign="top">excludes</td>
  454. <td valign="top">comma- or space-separated list of patterns
  455. of files that must be excluded</td>
  456. <td rowspan="2" valign="top" align="center">No, default none
  457. (except default excludes when true)</td>
  458. </tr>
  459. <tr>
  460. <td valign="top">excludesfile</td>
  461. <td valign="top">the name of a file; each line of this file is
  462. taken to be an exclude pattern.</td>
  463. </tr>
  464. <tr>
  465. <td valign="top">defaultexcludes</td>
  466. <td valign="top">Whether
  467. <a href="../dirtasks.html#defaultexcludes">default excludes</a>
  468. should be used</td>
  469. <td valign="top" align="center">No, default <i>true</i></td>
  470. </tr>
  471. <tr>
  472. <td valign="top">casesensitive</td>
  473. <td valign="top">Whether patterns are case-sensitive</td>
  474. <td valign="top" align="center">No, default <i>true</i></td>
  475. </tr>
  476. <tr>
  477. <td valign="top">followsymlinks</td>
  478. <td valign="top">Whether to follow symbolic links
  479. (see note <a href="#symlink">below</a>)</td>
  480. <td valign="top" align="center">No, default <i>true</i></td>
  481. </tr>
  482. </table>
  483. <p id="symlink"><b>Note</b>: All files/directories for which
  484. the canonical path is different from its path are considered symbolic
  485. links. On Unix systems this usually means the file really is a
  486. symbolic link but it may lead to false results on other
  487. platforms.
  488. </p>
  489. <h4 id="restrict">restrict</h4>
  490. <p>Restricts a nested resource collection using resource selectors:
  491. <table>
  492. <tr>
  493. <td valign="top"><b>Attribute</b></td>
  494. <td valign="top"><b>Description</b></td>
  495. <td align="center" valign="top"><b>Required</b></td>
  496. </tr>
  497. <tr>
  498. <td valign="top">cache</td>
  499. <td valign="top">Whether to cache results; disabling
  500. may seriously impact performance</td>
  501. <td valign="top" align="center">No, default <i>true</i></td>
  502. </tr>
  503. </table>
  504. <h5>Parameters specified as nested elements</h5>
  505. <p>A single resource collection is required.</p>
  506. <p>Nested resource selectors are used to "narrow down" the included
  507. resources, combined via a logical <i>AND</i>. These are patterned
  508. after <a href="selectors.html">file selectors</a> but are,
  509. unsurprisingly, targeted to resources.
  510. Several built-in resource selectors are available in the internal
  511. <a href="antlib.html">antlib</a>
  512. <code>org.apache.tools.ant.types.resources.selectors</code>:
  513. </p>
  514. <ul>
  515. <li><a href="#rsel.name">name</a> - select resources by name.</li>
  516. <li><a href="#rsel.exists">exists</a> - select existing resources.</li>
  517. <li><a href="#rsel.date">date</a> - select resources by date.</li>
  518. <li><a href="#rsel.type">type</a> - select resources by type.</li>
  519. <li><a href="#rsel.size">size</a> - select resources by size.</li>
  520. <li><a href="#rsel.instanceof">instanceof</a>
  521. - select resources by class or Ant datatype.</li>
  522. <li><a href="#rsel.and">and</a> - "and" nested resource selectors.</li>
  523. <li><a href="#rsel.or">or</a> - "or" nested resource selectors.</li>
  524. <li><a href="#rsel.not">not</a> - "not" a nested resource selector.</li>
  525. <li><a href="#rsel.none">none</a>
  526. - select resources selected by no nested resource selectors.</li>
  527. <li><a href="#rsel.majority">majority</a> - select resources selected
  528. by a majority of nested resource selectors.</li>
  529. <li><a href="selectors.html#modified">modified</a> - select resources which
  530. content has changed.</li>
  531. <li><a href="selectors.html#containsselect">contains</a> - select resources
  532. containing a particular text string.</li>
  533. <li><a href="selectors.html#regexpselect">containsregexp</a> - select
  534. resources whose contents match a particular regular expression.</li>
  535. <li><a href="#rsel.compare">compare</a> - select resources
  536. based on comparison to other resources.</li>
  537. <li><a href="selectors.html#readable">readable</a> -
  538. Select files (resources must be files) if they are readable.</li>
  539. <li><a href="selectors.html#writable">writable</a> -
  540. Select files (resources must be files) if they are writable.</li>
  541. </ul>
  542. <h5 id="rsel.name">name</h5>
  543. <p>Selects resources by name.</p>
  544. <table>
  545. <tr>
  546. <td valign="top"><b>Attribute</b></td>
  547. <td valign="top"><b>Description</b></td>
  548. <td align="center" valign="top"><b>Required</b></td>
  549. </tr>
  550. <tr>
  551. <td valign="top">name</td>
  552. <td valign="top">The name pattern to test using standard Ant
  553. patterns.</td>
  554. <td valign="top" align="center" rowspan="2">Exactly one of
  555. the two</td>
  556. </tr>
  557. <tr>
  558. <td valign="top">regex</td>
  559. <td valign="top">The regular expression matching files to select.</td>
  560. </tr>
  561. <tr>
  562. <td valign="top">casesensitive</td>
  563. <td valign="top">Whether name comparisons are case-sensitive</td>
  564. <td align="center" valign="top">No, default <i>true</i></td>
  565. </tr>
  566. <tr>
  567. <td valign="top">handledirsep</td>
  568. <td valign="top">
  569. If this is specified, the mapper will treat a \ character in a
  570. resource name or name attribute as a / for the purposes of
  571. matching. This attribute can be true or false, the default is
  572. false.
  573. <em>Since Ant 1.8.0</em>
  574. <td align="center" valign="top">No</td>
  575. </tr>
  576. </table>
  577. <h5 id="rsel.exists">exists</h5>
  578. <p>Selects existing resources.</p>
  579. <h5 id="rsel.date">date</h5>
  580. <p>Selects resources by date.</p>
  581. <table>
  582. <tr>
  583. <td valign="top"><b>Attribute</b></td>
  584. <td valign="top"><b>Description</b></td>
  585. <td align="center" valign="top"><b>Required</b></td>
  586. </tr>
  587. <tr>
  588. <td valign="top">millis</td>
  589. <td valign="top">The comparison date/time in ms since January 1, 1970</td>
  590. <td rowspan="2" align="center" valign="middle">One of these</td>
  591. </tr>
  592. <tr>
  593. <td valign="top">datetime</td>
  594. <td valign="top">The formatted comparison date/time</td>
  595. </tr>
  596. <tr>
  597. <td valign="top">pattern</td>
  598. <td valign="top">SimpleDateFormat-compatible pattern
  599. for use with the <code>datetime</code> attribute using the
  600. current locale</td>
  601. <td align="center" valign="top">
  602. No, default is "MM/dd/yyyy hh:mm a" using the US locale</td>
  603. </tr>
  604. <tr>
  605. <td valign="top">granularity</td>
  606. <td valign="top">The number of milliseconds leeway to use when
  607. comparing file modification times. This is needed because not
  608. every file system supports tracking the last modified time to
  609. the millisecond level.</td>
  610. <td align="center" valign="top">No; default varies by platform:
  611. FAT filesystems = 2 sec; Unix = 1 sec; NTFS = 1 ms.</td>
  612. </tr>
  613. <tr>
  614. <td valign="top">when</td>
  615. <td valign="top">One of "before", "after", "equal"</td>
  616. <td align="center" valign="top">No, default "equal"</td>
  617. </tr>
  618. </table>
  619. <h5 id="rsel.type">type</h5>
  620. <p>Selects resources by type (file or directory).</p>
  621. <table>
  622. <tr>
  623. <td valign="top"><b>Attribute</b></td>
  624. <td valign="top"><b>Description</b></td>
  625. <td align="center" valign="top"><b>Required</b></td>
  626. </tr>
  627. <tr>
  628. <td valign="top">type</td>
  629. <td valign="top">One of "file", "dir", "any" (<em>since Ant 1.8</em>)</td>
  630. <td align="center" valign="top">Yes</td>
  631. </tr>
  632. </table>
  633. <h5 id="rsel.size">size</h5>
  634. <p>Selects resources by size.</p>
  635. <table>
  636. <tr>
  637. <td valign="top"><b>Attribute</b></td>
  638. <td valign="top"><b>Description</b></td>
  639. <td align="center" valign="top"><b>Required</b></td>
  640. </tr>
  641. <tr>
  642. <td valign="top">size</td>
  643. <td valign="top">The size to compare</td>
  644. <td align="center" valign="top">Yes</td>
  645. </tr>
  646. <tr>
  647. <td valign="top">when</td>
  648. <td valign="top">One of "equal", "eq", "greater", "gt", "less", "lt",
  649. "ge" (greater or equal), "ne" (not equal), "le" (less or equal)</td>
  650. <td align="center" valign="top">No, default "equal"</td>
  651. </tr>
  652. </table>
  653. <h5 id="rsel.instanceof">instanceof</h5>
  654. <p>Selects resources by type.</p>
  655. <table>
  656. <tr>
  657. <td valign="top"><b>Attribute</b></td>
  658. <td valign="top"><b>Description</b></td>
  659. <td align="center" valign="top"><b>Required</b></td>
  660. </tr>
  661. <tr>
  662. <td valign="top">class</td>
  663. <td valign="top">The class of which the resource must be an instance</td>
  664. <td rowspan="2" align="center" valign="middle">One of these</td>
  665. </tr>
  666. <tr>
  667. <td valign="top">type</td>
  668. <td valign="top">The Ant type that must
  669. be assignable from the resource</td>
  670. </tr>
  671. <tr>
  672. <td valign="top">uri</td>
  673. <td valign="top">The uri in which <i>type</i> must be defined</td>
  674. <td valign="top">No</td>
  675. </tr>
  676. </table>
  677. <h5 id="rsel.and">and</h5>
  678. <p>Selects a resource if it is selected by all nested resource selectors.</p>
  679. <h5 id="rsel.or">or</h5>
  680. <p>Selects a resource if it is selected
  681. by at least one nested resource selector.</p>
  682. <h5 id="rsel.not">not</h5>
  683. <p>Negates the selection result of the single
  684. nested resource selector allowed.</p>
  685. <h5 id="rsel.none">none</h5>
  686. <p>Selects a resource if it is selected
  687. by no nested resource selectors.</p>
  688. <h5 id="rsel.majority">majority</h5>
  689. <p>Selects a resource if it is selected
  690. by the majority of nested resource selectors.</p>
  691. <table>
  692. <tr>
  693. <td valign="top"><b>Attribute</b></td>
  694. <td valign="top"><b>Description</b></td>
  695. <td align="center" valign="top"><b>Required</b></td>
  696. </tr>
  697. <tr>
  698. <td valign="top">allowtie</td>
  699. <td valign="top">Whether a tie (when there is an even number
  700. of nested resource selectors) is considered a majority</td>
  701. <td valign="top">No, default <i>true</i></td>
  702. </tr>
  703. </table>
  704. <h5 id="rsel.compare">compare</h5>
  705. <p>Selects a resource based on its comparison to one or more "control"
  706. resources using nested <a href="#rcmp">resource comparators</a>.</p>
  707. <table>
  708. <tr>
  709. <td valign="top"><b>Attribute</b></td>
  710. <td valign="top"><b>Description</b></td>
  711. <td align="center" valign="top"><b>Required</b></td>
  712. </tr>
  713. <tr>
  714. <td valign="top">when</td>
  715. <td valign="top">Comparison ("equal"/"eq", "greater"/"gt", "less"/"lt",
  716. "le" (less or equal), "ge" (greater or equal), "ne" (not equal).</td>
  717. <td valign="top">No, default "equal"</td>
  718. </tr>
  719. <tr>
  720. <td valign="top">against</td>
  721. <td valign="top">Quantifier ("all"/"each"/"every", "any"/"some",
  722. (exactly) "one", "most"/"majority", "none".</td>
  723. <td valign="top">No, default "all"</td>
  724. </tr>
  725. </table>
  726. <h6>Parameters specified as nested elements</h6>
  727. <p>The resources against which comparisons will be made must be specified
  728. using the nested &lt;control&gt; element, which denotes a
  729. <a href="#resources">resources</a> collection.</p>
  730. <h6>Examples</h6>
  731. <p>Assuming the namespace settings</p>
  732. <pre><code> rsel="antlib:org.apache.tools.ant.types.resources.selectors"
  733. rcmp="antlib:org.apache.tools.ant.types.resources.comparators"
  734. </code></pre>
  735. <pre>
  736. &lt;restrict&gt;
  737. &lt;fileset dir="src" includes="a,b,c,d,e,f,g" /&gt;
  738. &lt;rsel:compare when="le" against="all"&gt;
  739. &lt;control&gt;
  740. &lt;resource name="d" /&gt;
  741. &lt;/control&gt;
  742. &lt;rcmp:name /&gt;
  743. &lt;/rsel:compare&gt;
  744. &lt;/restrict&gt;
  745. </pre>
  746. <p>Selects files a, b, c, and d.</p>
  747. <pre>
  748. &lt;project rsel=&quot;antlib:org.apache.tools.ant.types.resources.selectors&quot;&gt;
  749. &lt;macrodef name=&quot;copyFromPath&quot;&gt;
  750. &lt;attribute name=&quot;todir&quot;/&gt;
  751. &lt;attribute name=&quot;refid&quot;/&gt;
  752. &lt;element name=&quot;nested-resource-selectors&quot; optional=&quot;yes&quot; implicit=&quot;true&quot;/&gt;
  753. &lt;sequential&gt;
  754. &lt;mkdir dir=&quot;@{todir}&quot; taskname=&quot;copyFromPath&quot;/&gt;
  755. &lt;copy todir=&quot;@{todir}&quot; taskname=&quot;copyFromPath&quot;&gt;
  756. &lt;restrict&gt;
  757. &lt;path refid=&quot;@{refid}&quot;/&gt;
  758. &lt;rsel:or&gt;
  759. &lt;nested-resource-selectors/&gt;
  760. &lt;/rsel:or&gt;
  761. &lt;/restrict&gt;
  762. &lt;flattenmapper/&gt;
  763. &lt;/copy&gt;
  764. &lt;/sequential&gt;
  765. &lt;/macrodef&gt;
  766. &lt;copyFromPath refid=&quot;classpath&quot; todir=&quot;todir&quot;&gt;
  767. &lt;rsel:name name=&quot;log4j.properties&quot;/&gt;
  768. &lt;rsel:name name=&quot;default.properties&quot;/&gt;
  769. &lt;/copyFromPath&gt;
  770. &lt;/project&gt;
  771. </pre>
  772. <p>Creates the <tt>todir</tt> directory and copies (if present) the
  773. files <tt>log4j.properties</tt> and <tt>default.properties</tt>
  774. from the Classpath (already used while compiling).
  775. </p>
  776. <pre>
  777. &lt;project&gt;
  778. &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;
  779. &lt;restrict id=&quot;missingfiles&quot;&gt;
  780. &lt;filelist refid=&quot;allfiles&quot;/&gt;
  781. &lt;rsel:not xmlns:rsel=&quot;antlib:org.apache.tools.ant.types.resources.selectors&quot;&gt;
  782. &lt;rsel:exists/&gt;
  783. &lt;/rsel:not&gt;
  784. &lt;/restrict&gt;
  785. &lt;echo&gt;These files are missed: ${toString:missingfiles}&lt;/echo&gt;
  786. &lt;/project&gt;
  787. </pre>
  788. <p>The resource collection <i>allfiles</i> defines a list of files which are expected. The restrict
  789. <i>missingfiles</i> uses the <tt>&lt;not&gt;&lt;exists&gt;</tt> selector for getting all files
  790. which are not present. Finally we use the <i>toString:</i> <a href="../using.html#pathshortcut">pathshortcut</a> for
  791. getting them in a readable form: <tt>[echo] These files are missed: ....foo.txt;....bar.txt</tt></p>
  792. <h4 id="sort">sort</h4>
  793. <p>Sorts a nested resource collection according to the resources'
  794. natural order, or by one or more nested <a href="#rcmp">resource
  795. comparators</a>:</p>
  796. <table>
  797. <tr>
  798. <td valign="top"><b>Attribute</b></td>
  799. <td valign="top"><b>Description</b></td>
  800. <td align="center" valign="top"><b>Required</b></td>
  801. </tr>
  802. <tr>
  803. <td valign="top">cache</td>
  804. <td valign="top">Whether to cache results; disabling
  805. may seriously impact performance</td>
  806. <td valign="top" align="center">No, default <i>true</i></td>
  807. </tr>
  808. </table>
  809. <h5>Parameters specified as nested elements</h5>
  810. <p>A single resource collection is required.</p>
  811. <p>The sort can be controlled and customized by specifying one or more
  812. resource comparators. Resources can be sorted according to multiple
  813. criteria; the first specified is the "outermost", while the last
  814. specified is the "innermost". Several built-in resource comparators
  815. are available in the internal <a href="antlib.html">antlib</a>
  816. <code>org.apache.tools.ant.types.resources.comparators</code>:
  817. </p>
  818. <h5 id="rcmp">Resource Comparators:</h5>
  819. <ul>
  820. <li><a href="#rcmp.name">name</a> - sort resources by name</li>
  821. <li><a href="#rcmp.exists">exists</a> - sort resources by existence</li>
  822. <li><a href="#rcmp.date">date</a> - sort resources by date</li>
  823. <li><a href="#rcmp.type">type</a> - sort resources by type</li>
  824. <li><a href="#rcmp.size">size</a> - sort resources by size</li>
  825. <li><a href="#rcmp.content">content</a> - sort resources by content</li>
  826. <li><a href="#rcmp.reverse">reverse</a> - reverse the natural sort order,
  827. or that of a single nested resource comparator</li>
  828. </ul>
  829. <h6 id="rcmp.name">name</h6>
  830. <p>Sort resources by name.</p>
  831. <h6 id="rcmp.exists">exists</h6>
  832. <p>Sort resources by existence.
  833. Not existing is considered "less than" existing.</p>
  834. <h6 id="rcmp.date">date</h6>
  835. <p>Sort resources by date.</p>
  836. <h6 id="rcmp.type">type</h6>
  837. <p>Sort resources by type (file or directory).
  838. Because directories contain files, they are considered "greater".</p>
  839. <h6 id="rcmp.size">size</h6>
  840. <p>Sort resources by size.</p>
  841. <h6 id="rcmp.content">content</h6>
  842. <p>Sort resources by content.</p>
  843. <table>
  844. <tr>
  845. <td valign="top"><b>Attribute</b></td>
  846. <td valign="top"><b>Description</b></td>
  847. <td align="center" valign="top"><b>Required</b></td>
  848. </tr>
  849. <tr>
  850. <td valign="top">binary</td>
  851. <td valign="top">Whether content should be compared in binary mode.
  852. If <i>false</i>, content will be compared without regard to
  853. platform-specific line-ending conventions.</td>
  854. <td valign="top">No, default <i>true</i></td>
  855. </tr>
  856. </table>
  857. <h6 id="rcmp.reverse">reverse</h6>
  858. <p>Reverse the natural sort order, or that of a single nested comparator.</p>
  859. <h5>Examples</h5>
  860. <pre>
  861. &lt;property name=&quot;eol&quot; value=&quot;${line.separator}&quot; /&gt;
  862. &lt;pathconvert property=&quot;sorted&quot; pathsep=&quot;${eol}&quot;&gt;
  863. &lt;sort&gt;
  864. &lt;tokens&gt;
  865. &lt;string value=&quot;foo bar etc baz&quot; /&gt;
  866. &lt;stringtokenizer /&gt;
  867. &lt;/tokens&gt;
  868. &lt;/sort&gt;
  869. &lt;/pathconvert&gt;</pre>
  870. <p>The resource of type string &quot;foo bar etc baz&quot; is split into four tokens by
  871. the stringtokenizer. These tokens are sorted and there <i>sorted</i> gets the value
  872. of &quot;bar baz etc foo&quot;.</p>
  873. <pre>
  874. &lt;sort&gt;
  875. &lt;fileset dir=&quot;foo&quot; /&gt;
  876. &lt;reverse xmlns=&quot;antlib:org.apache.tools.ant.types.resources.comparators&quot;&gt;
  877. &lt;date /&gt;
  878. &lt;/reverse&gt;
  879. &lt;/sort&gt;</pre>
  880. <p>This takes all files from <i>foo</i>
  881. and sorts them by modification date in reverse order.
  882. Because the resource comparators used (<code>&lt;reverse&gt;</code>
  883. and <code>&lt;date&gt;</code>) are in an internal antlib
  884. their namespace must be set explicitly.
  885. </p>
  886. <h4 id="first">first</h4>
  887. <p>Includes the first <i>count</i> resources from a nested resource collection.
  888. This can be used in conjunction with the <a href="#sort">sort</a> collection,
  889. for example, to select the first few oldest, largest, etc. resources from a
  890. larger collection.</p>
  891. <table>
  892. <tr>
  893. <td valign="top"><b>Attribute</b></td>
  894. <td valign="top"><b>Description</b></td>
  895. <td align="center" valign="top"><b>Required</b></td>
  896. </tr>
  897. <tr>
  898. <td valign="top">count</td>
  899. <td valign="top">The number of resources to include</td>
  900. <td valign="top" align="center">No, default 1</td>
  901. </tr>
  902. <tr>
  903. <td valign="top">cache</td>
  904. <td valign="top">Whether to cache results; disabling
  905. may seriously impact performance</td>
  906. <td valign="top" align="center">No, default <i>true</i></td>
  907. </tr>
  908. </table>
  909. <h5>Parameters specified as nested elements</h5>
  910. <p>A single resource collection is required.</p>
  911. <h4 id="last">last</h4>
  912. <p>Includes the last <i>count</i> resources from a nested resource collection.
  913. This can be used in conjunction with the <a href="#sort">sort</a> collection,
  914. for example, to select the last few oldest, largest, etc. resources from a
  915. larger collection. <em>Since Ant 1.7.1</em></p>
  916. <table>
  917. <tr>
  918. <td valign="top"><b>Attribute</b></td>
  919. <td valign="top"><b>Description</b></td>
  920. <td align="center" valign="top"><b>Required</b></td>
  921. </tr>
  922. <tr>
  923. <td valign="top">count</td>
  924. <td valign="top">The number of resources to include</td>
  925. <td valign="top" align="center">No, default 1</td>
  926. </tr>
  927. <tr>
  928. <td valign="top">cache</td>
  929. <td valign="top">Whether to cache results; disabling
  930. may seriously impact performance</td>
  931. <td valign="top" align="center">No, default <i>true</i></td>
  932. </tr>
  933. </table>
  934. <h5>Parameters specified as nested elements</h5>
  935. <p>A single resource collection is required.</p>
  936. <h4 id="allbutfirst">allbutfirst</h4>
  937. <p>Includes all elements except for the first <i>count</i> resources
  938. from a nested resource collection. This can be used in conjunction
  939. with the <a href="#sort">sort</a> collection, for example, to select
  940. all but the first few oldest, largest, etc. resources from a larger
  941. collection. <em>Since Ant 1.9.5</em></p>
  942. <table>
  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. <h5>Parameters specified as nested elements</h5>
  961. <p>A single resource collection is required.</p>
  962. <h4 id="allbutlast">allbutlast</h4>
  963. <p>Includes all elements except for the last <i>count</i> resources
  964. from a nested resource collection. This can be used in conjunction
  965. with the <a href="#sort">sort</a> collection, for example, to select
  966. all but the last few oldest, largest, etc. resources from a larger
  967. collection. <em>Since Ant 1.9.5</em></p>
  968. <table>
  969. <tr>
  970. <td valign="top"><b>Attribute</b></td>
  971. <td valign="top"><b>Description</b></td>
  972. <td align="center" valign="top"><b>Required</b></td>
  973. </tr>
  974. <tr>
  975. <td valign="top">count</td>
  976. <td valign="top">The number of resources to exclude</td>
  977. <td valign="top" align="center">No, default 1</td>
  978. </tr>
  979. <tr>
  980. <td valign="top">cache</td>
  981. <td valign="top">Whether to cache results; disabling
  982. may seriously impact performance</td>
  983. <td valign="top" align="center">No, default <i>true</i></td>
  984. </tr>
  985. </table>
  986. <h5>Parameters specified as nested elements</h5>
  987. <p>A single resource collection is required.</p>
  988. <h4 id="tokens">tokens</h4>
  989. <p>Includes the <a href="#string">string</a> tokens gathered from a nested
  990. resource collection. Uses the same tokenizers supported by the
  991. <a href="filterchain.html#tokenfilter">TokenFilter</a>. Imaginative
  992. use of this resource collection can implement equivalents for such Unix
  993. functions as <code>sort</code>, <code>grep -c</code>, <code>wc</code> and
  994. <code>wc -l</code>.</p>
  995. <table>
  996. <tr>
  997. <td valign="top"><b>Attribute</b></td>
  998. <td valign="top"><b>Description</b></td>
  999. <td align="center" valign="top"><b>Required</b></td>
  1000. </tr>
  1001. <tr>
  1002. <td valign="top">encoding</td>
  1003. <td valign="top">The encoding of the nested resources</td>
  1004. <td valign="top" align="center">No, default is platform default</td>
  1005. </tr>
  1006. <tr>
  1007. <td valign="top">cache</td>
  1008. <td valign="top">Whether to cache results; disabling
  1009. may seriously impact performance</td>
  1010. <td valign="top" align="center">No, default <i>true</i></td>
  1011. </tr>
  1012. </table>
  1013. <h5>Parameters specified as nested elements</h5>
  1014. <ul>
  1015. <li>A single resource collection is required.</li>
  1016. <li>One nested tokenizer may be specified. If omitted, a
  1017. <a href="filterchain.html#linetokenizer">LineTokenizer</a> will be used.
  1018. </li>
  1019. </ul>
  1020. <h5>Examples</h5>
  1021. <pre>&lt;concat&gt;
  1022. &lt;union&gt;
  1023. &lt;sort&gt;
  1024. &lt;tokens&gt;
  1025. &lt;resources refid="input" /&gt;
  1026. &lt;linetokenizer includedelims="true" /&gt;
  1027. &lt;/tokens&gt;
  1028. &lt;/sort&gt;
  1029. &lt;/union&gt;
  1030. &lt;/concat&gt;
  1031. </pre>
  1032. <p>Implements Unix <i>sort -u</i> against resource collection <i>input</i>.</p>
  1033. <h4 id="setlogic">Set operations</h4>
  1034. <p>The following resource collections implement set operations:</p>
  1035. <ul>
  1036. <li><a href="#union">union</a></li>
  1037. <li><a href="#intersect">intersect</a></li>
  1038. <li><a href="#difference">difference</a></li>
  1039. </ul>
  1040. <h4 id="union">union</h4>
  1041. <p>Union of nested resource collections.</p>
  1042. <h4 id="intersect">intersect</h4>
  1043. <p>Intersection of nested resource collections.</p>
  1044. <h4 id="difference">difference</h4>
  1045. <p>Difference of nested resource collections.</p>
  1046. <p>The following attributes apply to all set-operation resource collections:
  1047. </p>
  1048. <table>
  1049. <tr>
  1050. <td valign="top"><b>Attribute</b></td>
  1051. <td valign="top"><b>Description</b></td>
  1052. <td align="center" valign="top"><b>Required</b></td>
  1053. </tr>
  1054. <tr>
  1055. <td valign="top">cache</td>
  1056. <td valign="top">Whether to cache results; disabling
  1057. may seriously impact performance</td>
  1058. <td valign="top" align="center">No, default <i>true</i></td>
  1059. </tr>
  1060. </table>
  1061. <h5>Examples</h5>
  1062. <pre>
  1063. &lt;resources id=&quot;A&quot;&gt;
  1064. &lt;string value=&quot;a&quot;/&gt;
  1065. &lt;string value=&quot;b&quot;/&gt;
  1066. &lt;/resources&gt;
  1067. &lt;resources id=&quot;B&quot;&gt;
  1068. &lt;string value=&quot;b&quot;/&gt;
  1069. &lt;string value=&quot;c&quot;/&gt;
  1070. &lt;/resources&gt;
  1071. &lt;union id=&quot;union&quot;&gt;&lt;resources refid=&quot;A&quot;/&gt;&lt;resources refid=&quot;B&quot;/&gt;&lt;/union&gt;
  1072. &lt;intersect id=&quot;intersect&quot;&gt;&lt;resources refid=&quot;A&quot;/&gt;&lt;resources refid=&quot;B&quot;/&gt;&lt;/intersect&gt;
  1073. &lt;difference id=&quot;difference&quot;&gt;&lt;resources refid=&quot;A&quot;/&gt;&lt;resources refid=&quot;B&quot;/&gt;&lt;/difference&gt;
  1074. &lt;echo&gt;
  1075. A: ${toString:A} = a;b
  1076. B: ${toString:B} = b;c
  1077. union : ${toString:union} = a;b;c
  1078. intersect : ${toString:intersect} = b
  1079. difference: ${toString:difference} = a;c
  1080. &lt;/echo&gt;
  1081. </pre>
  1082. <h4 id="mappedresources">mappedresources</h4>
  1083. <p><em>Since Ant 1.8.0</em></p>
  1084. <p>Wraps another resource collection and maps the names of the nested
  1085. resources using a <a href="mapper.html">mapper</a>.</p>
  1086. <p>Even if <em>mappedresources</em> wraps a resource collection that
  1087. consists of file-system based resources, <em>mappedresources</em>
  1088. will not appear to be file-system based. This means you can't
  1089. use <em>mappedresources</em> with tasks that only allow file-system
  1090. based resources.</p>
  1091. <h5>Parameters specified as attributes</h5>
  1092. <table>
  1093. <tr>
  1094. <td valign="top"><b>Attribute</b></td>
  1095. <td valign="top"><b>Description</b></td>
  1096. <td align="center" valign="top"><b>Required</b></td>
  1097. </tr>
  1098. <tr>
  1099. <td valign="top">cache</td>
  1100. <td valign="top">Whether to cache results; enabling
  1101. may improve performance. <em>Since Ant 1.8.1</em></td>
  1102. <td valign="top" align="center">No, default <i>false</i></td>
  1103. </tr>
  1104. <tr>
  1105. <td valign="top">enablemultiplemappings</td>
  1106. <td valign="top">
  1107. If true the the collection will use all the mappings for a
  1108. given source path. If false the it will only process the first
  1109. resource.
  1110. <em>since Ant 1.8.1</em></td>
  1111. <td align="center">No - defaults to false.</td>
  1112. </tr>
  1113. </table>
  1114. <h5>Parameters specified as nested elements</h5>
  1115. <p>A single resource collection is required.</p>
  1116. <p>A single <a href="mapper.html">mapper</a> can be used to map
  1117. names. If no mapper has been given (which doesn't make any sense,
  1118. honestly), an identity mapper will be used.</p>
  1119. <h5>Examples</h5>
  1120. <p>Copies all files from a given directory to a target directory
  1121. adding ".bak" as an extension. Note this could be done with a
  1122. <em>mapper</em> nested into <em>copy</em> directly as well.</p>
  1123. <pre>
  1124. &lt;copy todir="${target}"&gt;
  1125. &lt;mappedresources&gt;
  1126. &lt;fileset dir="${src}"/&gt;
  1127. &lt;globmapper from="*" to="*.bak"/&gt;
  1128. &lt;/mappedresources&gt;
  1129. &lt;/copy&gt;
  1130. </pre>
  1131. <p>Creates a WAR archive adding all CLASSPATH entries that are files
  1132. to the <code>WEB-INF/lib</code> directory without keeping their
  1133. files-system structure.</p>
  1134. <pre>
  1135. &lt;war destfile="${output}"&gt;
  1136. &lt;mappedresources&gt;
  1137. &lt;restrict&gt;
  1138. &lt;path path="${java.class.path}"/&gt;
  1139. &lt;type type="file"/&gt;
  1140. &lt;/restrict&gt;
  1141. &lt;chainedmapper&gt;
  1142. &lt;flattenmapper/&gt;
  1143. &lt;globmapper from="*" to="WEB-INF/lib/*"/&gt;
  1144. &lt;/chainedmapper&gt;
  1145. &lt;/mappedresources&gt;
  1146. &lt;/war&gt;
  1147. </pre>
  1148. <h4 id="archives">archives</h4>
  1149. <p><em>Since Ant 1.8.0</em></p>
  1150. <p>This resource collection accepts an arbitrary number of nested
  1151. resources and assumes that all those resources must be either ZIP or
  1152. TAR archives. The resources returned
  1153. by <code>&lt;archives&gt;</code> are the contents of the nested
  1154. archives.</p>
  1155. <p>This resource collection is a generalization
  1156. of <a href="../Tasks/zip.html#zipgroupfileset">zipgroupfileset</a>
  1157. which is only supported by the zip family of tasks.</p>
  1158. <p><em>archives</em> doesn't support any attributes.</p>
  1159. <h5>Parameters specified as nested elements</h5>
  1160. <p><code>&lt;archives&gt;</code> has two nested
  1161. elements <code>&lt;zips&gt;</code> and
  1162. <code>&lt;tars&gt;</code> that are <a href="#union">unions</a>
  1163. themselves, i.e. they accept arbitrary many resource(collection)s
  1164. as nested elements.</p>
  1165. <p>The nested resources of &lt;zips&gt; are treated as ZIP archives,
  1166. the nested resources of &lt;tars&gt; as TAR archives.</p>
  1167. <h5>Examples</h5>
  1168. <p>Copies all files from all jars that are on the classpath
  1169. to <code>${target}</code>.</p>
  1170. <pre>
  1171. &lt;copy todir="${target}"&gt;
  1172. &lt;archives&gt;
  1173. &lt;zips&gt;
  1174. &lt;restrict&gt;
  1175. &lt;path path="${java.class.path}"/&gt;
  1176. &lt;name name="*.jar"/&gt;
  1177. &lt;/restrict&gt;
  1178. &lt;/zips&gt;
  1179. &lt;/archives&gt;
  1180. &lt;/copy&gt;
  1181. </pre>
  1182. <h4 id="resourcelist">resourcelist</h4>
  1183. <p><em>Since Ant 1.8.0</em></p>
  1184. <p>This resource collection accepts an arbitrary number of nested
  1185. resources, reads those resources and returns a resource for each
  1186. line read.</p>
  1187. <p>If the line contains a colon, Ant will try to use it as an URL and
  1188. if that fails (or the line doesn't contain a colon) will return a
  1189. file resource with the line's content as its name.</p>
  1190. <p>Properties will be expanded for each line. If the property
  1191. expansion yields a resource object rather than a string (for example
  1192. because of custom property helpers), the resources will be returned
  1193. directly.</p>
  1194. <p><code>&lt;resourcelist&gt;</code> is a generalization
  1195. of <a href="filelist.html"><code>&lt;filelist&gt;</code></a>.</p>
  1196. <table>
  1197. <tr>
  1198. <td valign="top"><b>Attribute</b></td>
  1199. <td valign="top"><b>Description</b></td>
  1200. <td align="center" valign="top"><b>Required</b></td>
  1201. </tr>
  1202. <tr>
  1203. <td valign="top">encoding</td>
  1204. <td valign="top">The encoding of the nested resources</td>
  1205. <td valign="top" align="center">No, default is platform default</td>
  1206. </tr>
  1207. </table>
  1208. <h5>Parameters specified as nested elements</h5>
  1209. <p><code>&lt;resourcelist&gt;</code> accepts arbitrary many
  1210. resource(collection)s as nested elements.</p>
  1211. <p>In addition <code>&lt;resourcelist&gt;</code> supports
  1212. nested <code>&lt;filterchain&gt;</code> elements that can be used
  1213. to filter/modify the read resources before their lines get
  1214. expanded. Such a nested element corresponds to
  1215. a <a href="filterchain.html">filterchain</a>.</p>
  1216. <h5>Examples</h5>
  1217. <p>The following example copies a file from the first URL of
  1218. several alternatives that can actually be reached. It assumes
  1219. that the file mirrors.txt looks like</p>
  1220. <pre>
  1221. mirrors.txt:
  1222. http://best.mirror.example.org/
  1223. http://second.best.mirror.example.org/mirror/of/best/
  1224. https://yet.another.mirror/
  1225. http://the.original.site/
  1226. </pre>
  1227. <pre>
  1228. &lt;copy todir="${target}"&gt;
  1229. &lt;first&gt;
  1230. &lt;restrict&gt;
  1231. &lt;resourcelist&gt;
  1232. &lt;file file="mirrors.txt"/&gt;
  1233. &lt;/resourcelist&gt;
  1234. &lt;exists/&gt;
  1235. &lt;/restrict&gt;
  1236. &lt;/first&gt;
  1237. &lt;/copy&gt;
  1238. </pre>
  1239. </body>
  1240. </html>