You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

resources.html 51 KiB

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