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

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