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

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