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.

index.html 110 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Ant</title>
  5. </head>
  6. <body>
  7. <h1>Ant User Manual</h1>
  8. <p>by</p>
  9. <!-- Names are in alphabetical order, on last name -->
  10. <ul>
  11. <li>James Duncan Davison (<a href="mailto:duncan@x180.com">duncan@x180.com</a>)</li>
  12. <li>Tom Dimock (<a href="mailto:tad1@cornell.edu">tad1@cornell.edu</a>)</li>
  13. <li>Arnout J. Kuiper (<a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a>)</li>
  14. <li>Stefano Mazzocchi (<a href="mailto:stefano@apache.org">stefano@apache.org</a>)</li>
  15. <li>Sam Ruby (<a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a>)</li>
  16. </ul>
  17. <p>Version 1.0.8.1 - 2000/06/13</p>
  18. <hr>
  19. <h2>Table of Contents</h2>
  20. <ul>
  21. <li><a href="#introduction">Introduction</a></li>
  22. <li><a href="#getting">Getting Ant</a></li>
  23. <li><a href="#buildingant">Building Ant</a></li>
  24. <li><a href="#installing">Installing Ant</a></li>
  25. <li><a href="#running">Running Ant</a></li>
  26. <li><a href="#buildfile">Writing a simple buildfile</a>
  27. <li><a href="#directorybasedtasks">Directory based tasks</a></li>
  28. <li><a href="#tasks">Built in Tasks</a>
  29. <li><a href="#optionaltasks">Optional Tasks</a>
  30. <li><a href="#writingowntask">Writing your own task</a></li>
  31. <li><a href="#license">License</a></li>
  32. <li><a href="#feedback">Feedback</a></li>
  33. </ul>
  34. <hr>
  35. <h2><a name="introduction">Introduction</a></h2>
  36. <p>Ant is a Java based build tool. In theory it is kind of like make without
  37. makes wrinkles.</p>
  38. <h3>Why?</h3>
  39. <p>Why another build tool when there is already make, gnumake, nmake, jam, and
  40. others? Because all of those tools have limitations that its original author
  41. couldn't live with when developing software across multiple platforms. Make like
  42. tools are inherently shell based. They evaluate a set of dependencies and then
  43. execute commands not unlike what you would issue on a shell. This means that you
  44. can easily extend these tools by using or writing any program for the OS that
  45. you are working on. However, this also means that you limit yourself to the OS,
  46. or at least the OS type such as Unix, that you are working on.</p>
  47. <p>Makefiles are inherently evil as well. Anybody who has worked on them for any
  48. time has run into the dreaded tab problem. &quot;Is my command not executing
  49. because I have a space in front of my tab!!!&quot; said the original author of
  50. Ant way too many times. Tools like Jam took care of this to a great degree, but
  51. still use yet another format to use and remember.</p>
  52. <p>Ant is different. Instead a model where it is extended with shell based
  53. commands, it is extended using Java classes. Instead of writing shell commands,
  54. the configuration files are XML based calling out a target tree where various
  55. tasks get executed. Each task is run by an object which implements a particular
  56. Task interface.</p>
  57. <p>Granted, this removes some of the expressive power that is inherent by being
  58. able to construct a shell command such as `find . -name foo -exec rm {}` but it
  59. gives you the ability to be cross platform. To work anywhere and everywhere. And
  60. hey, if you really need to execute a shell command, Ant has an exec rule that
  61. allows different commands to be executed based on the OS that it is executing
  62. on.</p>
  63. <hr>
  64. <h2><a name="getting">Getting Ant</a></h2>
  65. <h3>Binary edition</h3>
  66. <p>The latest stable version of Ant can be downloaded from <a
  67. href="http://jakarta.apache.org/builds/tomcat/release/v3.0/ant.zip">http://jakarta.apache.org/builds/tomcat/release/v3.0/ant.zip</a>.
  68. If you like living on the edge, you can download the latest version from <a
  69. href="http://jakarta.apache.org/builds/tomcat/nightly/ant.zip">http://jakarta.apache.org/builds/tomcat/nightly/ant.zip</a>.</p>
  70. <h3>Source edition</h3>
  71. <p>If you prefer the source edition, you can download Ant from <a
  72. href="http://jakarta.apache.org/builds/tomcat/release/v3.0/src/jakarta-tools.src.zip">http://jakarta.apache.org/builds/tomcat/release/v3.0/src/jakarta-tools.src.zip</a>
  73. (latest stable) or from <a
  74. href="http://jakarta.apache.org/from-cvs/jakarta-tools/">http://jakarta.apache.org/from-cvs/jakarta-ant/</a>
  75. (current). See the section <a href="#buildingant">Building Ant</a> on how to
  76. build Ant from the source code.</p>
  77. <hr>
  78. <h2><a name="buildingant">Building Ant</a></h2>
  79. <p>
  80. Download and install the Java API for XML Parsing kit from
  81. <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>.
  82. Make sure the "jaxp.jar" and "parser.jar" files are in your class
  83. path.
  84. </p>
  85. <p>Go to the directory <code>jakarta-ant</code>.</p>
  86. <p>Make sure the JDK is in you path.</p>
  87. <p>Run <code>bootstrap.bat</code> (Windows) or <code>bootstrap.sh</code> (UNIX)
  88. to build a bootstrap version of Ant.</p>
  89. <p>When finished, use</p>
  90. <blockquote>
  91. <p><code>build.bat -Dant.dist.dir=&lt;directory to install Ant&gt; dist</code></p>
  92. </blockquote>
  93. <p>for Windows, and</p>
  94. <blockquote>
  95. <p><code>build.sh -Dant.dist.dir=&lt;directory to install Ant&gt; dist</code></p>
  96. </blockquote>
  97. <p>for UNIX, to create a binary distribution of Ant. This distribution can be
  98. found in the directory you specified.</p>
  99. <hr>
  100. <h2><a name="installing">Installing Ant</a></h2>
  101. <p>The binary distribution of Ant consists of three directories: <code>bin</code>,
  102. <code>docs</code> and <code>lib</code>. Only the <code>bin</code> and <code>lib</code>
  103. directory are crucial for running Ant. To run Ant, the following must be done:</p>
  104. <ul>
  105. <li>Add the <code>bin</code> directory to your path.</li>
  106. <li>Set the ANT_HOME environment variable. This should be set to the directory
  107. which contains the <code>bin</code> and <code>lib</code> directory.</li>
  108. <li>Set the JAVA_HOME environment variable. This should be set to the
  109. directory where the JDK is installed.</li>
  110. </ul>
  111. <h3>Windows</h3>
  112. <p>Assume Ant is installed in <code>c:\ant\</code>. The following sets up the
  113. environment:</p>
  114. <pre>set ANT_HOME=c:\ant
  115. set JAVA_HOME=c:\jdk1.2.2
  116. set PATH=%PATH%;%ANT_HOME%\bin</pre>
  117. <h3>Unix (bash)</h3>
  118. <p>Assume Ant is installed in <code>/usr/local/ant</code>. The following sets up
  119. the environment:</p>
  120. <pre>export ANT_HOME=/usr/local/ant
  121. export JAVA_HOME=/usr/local/jdk-1.2.2
  122. export PATH=${PATH}:${ANT_HOME}/bin</pre>
  123. <h3>Advanced</h3>
  124. <p>There are lots of variants that can be used to run Ant. What you need is at
  125. least the following:</p>
  126. <p>The classpath for Ant must contain <code>ant.jar</code> and <code>xml.jar</code>.</p>
  127. <p>When you need JDK functionality (like a <a href="#javac">javac</a> task, or a
  128. <a href="#rmic">rmic</a> task), then for JDK 1.1, the <code>classes.zip</code>
  129. file of the JDK must be added to the classpath; for JDK 1.2, <code>tools.jar</code>
  130. must be added.</p>
  131. <p>When you are executing platform specific applications (like the <a
  132. href="#exec">exec</a> task, or the <a href="#cvs">cvs</a> task), the property <code>ant.home</code>
  133. must be set to the directory containing a bin directory, which contains the <code>antRun</code> shell script necessary to run execs on Unix.</p>
  134. <hr>
  135. <h2><a name="running">Running Ant</a></h2>
  136. <p>Running Ant is simple, when you installed it as described in the previous
  137. section. Just type <code>ant</code>.</p>
  138. <p>When nothing is specified, Ant looks for a <code>build.xml</code> file in the
  139. current directory. When found, it uses that file as a buildfile. To make Ant use
  140. another buildfile, use the commandline option <i>-buildfile &lt;file&gt;</i>,
  141. where <i>&lt;file&gt;</i> is the buildfile you want to use.</p>
  142. <p>You can also set properties which override properties specified in the
  143. buildfile. This can be done with the <i>-D&lt;property&gt;=&lt;value&gt;</i>
  144. option, where <i>&lt;property&gt;</i> is the name of the property and <i>&lt;value&gt;</i>
  145. the value.</p>
  146. <p>To more options are <i>-quiet</i> which instructs Ant to print less
  147. information on the console when running. The option <i>-verbose</i> on the other
  148. hand makes Ant print more information on the console.</p>
  149. <p>It is also possible to specify the target that should be executed. Default
  150. the target that is mentioned in the <i>default</i> attribute of the project is
  151. used. This can be overridden by adding the target name to the end of the
  152. commandline.</p>
  153. <p>Commandline option summary:</p>
  154. <pre>ant [options] [target]
  155. Options:
  156. -help print this message
  157. -quiet be extra quiet
  158. -verbose be extra verbose
  159. -logfile &lt;file&gt; use given file for log
  160. -buildfile &lt;file&gt; use given buildfile
  161. -D&lt;property&gt;=&lt;value&gt; use value for given property</pre>
  162. <h3>Examples</h3>
  163. <blockquote>
  164. <pre>ant</pre>
  165. </blockquote>
  166. <p>runs Ant using the <code>build.xml</code> file in the current directory, on
  167. the default target.</p>
  168. <blockquote>
  169. <pre>ant -buildfile test.xml</pre>
  170. </blockquote>
  171. <p>runs Ant using the <code>test.xml</code> file in the current directory, on
  172. the default target.</p>
  173. <blockquote>
  174. <pre>ant -buildfile test.xml dist</pre>
  175. </blockquote>
  176. <p>runs Ant using the <code>test.xml</code> file in the current directory, on a
  177. target called <code>dist</code>.</p>
  178. <blockquote>
  179. <pre>ant -buildfile test.xml -Dbuild=build/classes dist</pre>
  180. </blockquote>
  181. <p>runs Ant using the <code>test.xml</code> file in the current directory, on a
  182. target called <code>dist</code>. It also sets the <i>build</i> property to the
  183. value <i>build/classes</i>.</p>
  184. <h3>Running Ant by hand</h3>
  185. <p>When you have installed Ant in the do-it-yourself way, Ant can be started
  186. with:</p>
  187. <blockquote>
  188. <pre>set CLASSPATH=c:\ant\lib\ant.jar;c:\ant\lib\xml.jar;c:\jdk1.2.2\lib\tools.jar
  189. java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]</pre>
  190. </blockquote>
  191. <p>These instructions actually do exactly the same as the <code>ant</code>
  192. command. The options and target are the same as when running Ant with the <code>ant</code>
  193. command.</p>
  194. <hr>
  195. <h2><a name="buildfile">Writing a simple buildfile</a></h2>
  196. <p>The buildfile is written in XML. Each buildfile contains one project.</p>
  197. <h3>Projects</h3>
  198. <p>A project has three attributes:</p>
  199. <table border="1" cellpadding="2" cellspacing="0">
  200. <tr>
  201. <td valign="top"><b>Attribute</b></td>
  202. <td valign="top"><b>Description</b></td>
  203. <td align="center" valign="top"><b>Required</b></td>
  204. </tr>
  205. <tr>
  206. <td valign="top">name</td>
  207. <td valign="top">the name of the project.</td>
  208. <td align="center" valign="top">Yes</td>
  209. </tr>
  210. <tr>
  211. <td valign="top">default</td>
  212. <td valign="top">the default target to use when no target is supplied.</td>
  213. <td align="center" valign="top">Yes</td>
  214. </tr>
  215. <tr>
  216. <td valign="top">basedir</td>
  217. <td valign="top">the base directory from which all path calculations are
  218. done. This attribute might be overridden by setting the &quot;basedir&quot;
  219. property on forehand. When this is done, it might be ommitted in the
  220. project tag.</td>
  221. <td align="center" valign="top">Yes</td>
  222. </tr>
  223. </table>
  224. <p>Each project defines one or more targets. A target is a set of tasks you want
  225. to be executed. When starting Ant, you can select which target you want to have
  226. executed. When no target is given, the project's default is used.</p>
  227. <h3>Targets</h3>
  228. <p>A target can depend on other targets. You might have a target for compiling,
  229. for instance, and a target for creating a distributable. You can only build a
  230. distributable when you have compiled first, so the distribute target depends on
  231. the compile target. Ant resolves all these dependencies.</p>
  232. <p>Ant tries to execute the targets in the <i>depends</i> attribute in the order
  233. they appear (from left to right). Keep in mind that it is possible that a target
  234. can get executed earlier when an earlier target depends on it:</p>
  235. <blockquote>
  236. <pre>&lt;target name=&quot;A&quot;/&gt;
  237. &lt;target name=&quot;B&quot; depends=&quot;A&quot;/&gt;
  238. &lt;target name=&quot;C&quot; depends=&quot;B&quot;/&gt;
  239. &lt;target name=&quot;D&quot; depends=&quot;C,B,A&quot;/&gt;</pre>
  240. </blockquote>
  241. <p>Suppose we want to execute target D. From its <i>depends</i> attribute, you
  242. might think that first target C, then B and then A is executed. Wrong! C depends
  243. on B, and B depends on A, so first A is executed, then B, then C, and finally D.</p>
  244. <p>A target gets executed only once. Even when more targets depend on it (see
  245. the previous example).</p>
  246. <p>A target has also the ability to perform its execution if a property has been
  247. set. This allows, for example, better control on the building process depending
  248. on the state of the system (java version, OS, command line properties, etc...).
  249. To make target <i>sense</i> this property you should add the <i>if</i> attribute
  250. with the name of the property that the target should react to, for example</p>
  251. <blockquote>
  252. <pre>&lt;target name=&quot;build-module-A&quot; if=&quot;module-A-present&quot;/&gt;</pre>
  253. </blockquote>
  254. <p>If no <i>if</i> attribute is present, the target will always be executed.</p>
  255. <p>It is a good practice to place your <a href="#property">property</a> and <a
  256. href="#tstamp">tstamp</a> tasks in a so called initialization target, on which
  257. all other targets depend. Make sure that that target is always the first one in
  258. the depends list of the other targets. In this manual, most initialization targets
  259. have the name "init".</p>
  260. <p>A target has the following attributes:</p>
  261. <table border="1" cellpadding="2" cellspacing="0">
  262. <tr>
  263. <td valign="top"><b>Attribute</b></td>
  264. <td valign="top"><b>Description</b></td>
  265. <td align="center" valign="top"><b>Required</b></td>
  266. </tr>
  267. <tr>
  268. <td valign="top">name</td>
  269. <td valign="top">the name of the project.</td>
  270. <td align="center" valign="top">Yes</td>
  271. </tr>
  272. <tr>
  273. <td valign="top">depends</td>
  274. <td valign="top">a comma separated list of names of targets on which this
  275. target depends.</td>
  276. <td align="center" valign="top">No</td>
  277. </tr>
  278. <tr>
  279. <td valign="top">if</td>
  280. <td valign="top">the name of the property that must be set in order for this
  281. target to execute.</td>
  282. <td align="center" valign="top">No</td>
  283. </tr>
  284. </table>
  285. <h3>Tasks</h3>
  286. <p>A task is a piece of code that can be executed.</p>
  287. <p>A task can have multiple attributes (or arguments if you prefer). The value
  288. of an attribute might contain references to a property. These references will be
  289. resolved before the task is executed.</p>
  290. <p>Tasks have a common structure:</p>
  291. <blockquote>
  292. <pre>&lt;name attribute1=&quot;value1&quot; attribute2=&quot;value2&quot; ... /&gt;</pre>
  293. </blockquote>
  294. <p>where name is the name of the task, attribute-x the attribute name, and
  295. value-x the value of this attribute.</p>
  296. <p>There is a set of <a href="#tasks">built in tasks</a>, but it is also very
  297. easy to <a href="#writingowntask">write your own</a>.</p>
  298. <h3>Properties</h3>
  299. <p>A project can have a set of properties. These might be set in the buildfile
  300. by the <a href="#property">property task</a>, or might be set outside Ant. A
  301. property has a name and a value. Properties might be used in in the value of
  302. task attributes. This is done by placing the property name between
  303. &quot;${&quot; and &quot;}&quot; in the attribute value.</p>
  304. <p>If there is a property called &quot;builddir&quot; with the value
  305. &quot;build&quot;, then this could be used in an attribute like this: &quot;${builddir}/classes&quot;.
  306. This is resolved as &quot;build/classes&quot;.</p>
  307. <h3>Token Filters</h3>
  308. <p>A project can have a set of tokens that might be automatically expanded if
  309. found when a file is copied, when the filtering-copy behavior is selected in the
  310. tasks that support this. These might be set in the buildfile
  311. by the <a href="#filter">filter task</a>.&nbsp;</p>
  312. <p>Since this can be a very harmful behavior, the tokens in the files <b>must</b>
  313. be of the form<i> @token@</i> where <i>token</i> is the token name that is set
  314. in the filter task. This token syntax matches the syntax of other build systems
  315. that perform such filtering and remains sufficiently orthogonal to most
  316. programming and scripting languages, as well with documentation systems.</p>
  317. <p>Note: in case a token with the format @token@ if found in a file but no
  318. filter is associated with that token, no changes take place. So, no escaping
  319. method is present, but as long as you choose appropriate names for your tokens,
  320. this should not cause problems.</p>
  321. <h3>Examples</h3>
  322. <blockquote>
  323. <pre>&lt;project name=&quot;foo&quot; default=&quot;dist&quot; basedir=&quot;.&quot;&gt;
  324. &lt;target name=&quot;init&quot;&gt;
  325. &lt;tstamp/&gt;
  326. &lt;property name=&quot;build&quot; value=&quot;build&quot; /&gt;
  327. &lt;property name=&quot;dist&quot; value=&quot;dist&quot; /&gt;
  328. &lt;filter token=&quot;version&quot; value=&quot;1.0.3&quot; /&gt;
  329. &lt;filter token=&quot;year&quot; value=&quot;2000&quot; /&gt;
  330. &lt;/target&gt;
  331. &lt;target name=&quot;prepare&quot; depends=&quot;init&quot;&gt;
  332. &lt;mkdir dir=&quot;${build}&quot; /&gt;
  333. &lt;/target&gt;
  334. &lt;target name=&quot;compile&quot; depends=&quot;prepare&quot;&gt;
  335. &lt;javac srcdir=&quot;${src}&quot; destdir=&quot;${build}&quot; filtering=&quot;on&quot;/&gt;
  336. &lt;/target&gt;
  337. &lt;target name=&quot;dist&quot; depends=&quot;compile&quot;&gt;
  338. &lt;mkdir dir=&quot;${dist}/lib&quot; /&gt;
  339. &lt;jar jarfile=&quot;${dist}/lib/foo${DSTAMP}.jar&quot;
  340. basedir=&quot;${build}&quot; items=&quot;com&quot;/&gt;
  341. &lt;/target&gt;
  342. &lt;target name=&quot;clean&quot; depends=&quot;init&quot;&gt;
  343. &lt;deltree dir=&quot;${build}&quot; /&gt;
  344. &lt;deltree dir=&quot;${dist}&quot; /&gt;
  345. &lt;/target&gt;
  346. &lt;/project&gt;
  347. </pre>
  348. </blockquote>
  349. <hr>
  350. <h2><a name="directorybasedtasks">Directory based tasks</a></h2>
  351. <p>Some tasks use directory trees for the task they perform. For instance, the <a
  352. href="#javac">Javac task</a> which works upon a directory tree with .java files.
  353. Sometimes it can be very useful to work on a subset of that directory tree. This
  354. section describes how you can select a subset of such a directory tree.</p>
  355. <p>Ant gives you two ways to create a subset, which both can be used at the same
  356. time:</p>
  357. <ul>
  358. <li>Only include files/directories that match at least one pattern of a set of
  359. patterns</li>
  360. <li>Exclude files/directories that match at least one pattern a set of
  361. patterns</li>
  362. </ul>
  363. <p>When both inclusion and exclusion are used, only files/directories that match
  364. the include patterns, and don't match the exclude patterns are used.</p>
  365. <h3>Patterns</h3>
  366. <p>As described earlier, patterns are used for the inclusion and exclusion.
  367. These patterns look very much like the patterns used in DOS and UNIX:</p>
  368. <p>'*' matches zero or more characters, '?' matches one character.</p>
  369. <p>Examples:</p>
  370. <p>'*.java' matches '.java', 'x.java' and 'FooBar.java', but not 'FooBar.xml'
  371. (does not end with '.java').</p>
  372. <p>'?.java' matches 'x.java', 'A.java', but not '.java' or 'xyz.java' (both
  373. don't have one character before '.java').</p>
  374. <p>Combinations of '*'s and '?'s are allowed.</p>
  375. <p>Matching is done per-directory. This means that first the first directory in
  376. the pattern is matched against the first directory in the path to match. Then
  377. the second directories are matched, and so on. E.g. when we have the pattern '/?abc/*/*.java'
  378. and the path '/xabc/foobar/test.java', then first '?abc' is matched with 'xabc',
  379. then '*' is matched with 'foobar' and finally '*.java' is matched with 'test.java'.
  380. They all match so the path matches the pattern.</p>
  381. <p>Too make things a bit more flexible, we add one extra feature, which makes it
  382. possible to match multiple directory levels. This can be used to match a
  383. complete directory tree, or a file anywhere in the directory tree. To do this, '**'
  384. must be used as the name of a directory. When '**' is used as the name of a
  385. directory in the pattern, it matches zero or more directories. For instance:
  386. '/test/**' matches all files/directories under '/test/', such as '/test/x.java',
  387. or '/test/foo/bar/xyz.html', but not '/xyz.xml'.</p>
  388. <p>There is one &quot;shorthand&quot;, if a pattern ends with '/' or '\', then '**'
  389. is appended. E.g. &quot;mypackage/test/&quot; is interpreted as were it &quot;mypackage/test/**&quot;.</p>
  390. <p>Examples:</p>
  391. <table border="1" cellpadding="2" cellspacing="0">
  392. <tr>
  393. <td valign="top">**/CVS/*</td>
  394. <td valign="top">Matches all files in CVS directories, that can be located
  395. anywhere in the directory tree.
  396. <p>Matches:</p>
  397. <p>CVS/Repository<br>
  398. org/apache/CVS/Entries<br>
  399. org/apache/jakarta/tools/ant/CVS/Entries</p>
  400. <p>But not:</p>
  401. <p>org/apache/CVS/foo/bar/Entries ('foo/bar/' part does not match)</td>
  402. </tr>
  403. <tr>
  404. <td valign="top">org/apache/jakarta/**</td>
  405. <td valign="top">Matches all files in the org/apache/jakarta directory tree.
  406. <p>Matches:</p>
  407. <p>org/apache/jakarta/tools/ant/docs/index.html<br>
  408. org/apache/jakarta/test.xml</p>
  409. <p>But not:</p>
  410. <p>org/apache/xyz.java ('jakarta'/' part is missing)</td>
  411. </tr>
  412. <tr>
  413. <td valign="top">org/apache/**/CVS/*</td>
  414. <td valign="top">Matches all files in CVS directories, that are located
  415. anywhere in the directory tree under org/apache.
  416. <p>Matches:</p>
  417. <p>org/apache/CVS/Entries<br>
  418. org/apache/jakarta/tools/ant/CVS/Entries</p>
  419. <p>But not:</p>
  420. <p>org/apache/CVS/foo/bar/Entries ('foo/bar/' part does not match)</td>
  421. </tr>
  422. <tr>
  423. <td valign="top">**/test/**</td>
  424. <td valign="top">Matches all files which have a directory 'test' in their
  425. path, including 'test' as a filename.</td>
  426. </tr>
  427. </table>
  428. <p>When these patterns are used in inclusion and exclusion, you have a powerful
  429. way to select just the files you want.</p>
  430. <h3>Examples</h3>
  431. <pre> &lt;copydir src=&quot;${src}&quot;
  432. dest=&quot;${dist}&quot;
  433. includes=&quot;**/images/*&quot;
  434. excludes=&quot;**/*.gif&quot; /&gt;</pre>
  435. <p>This copies all files in directories called &quot;images&quot;, that are
  436. located in the directory tree &quot;${src}&quot; to the destination &quot;${dist}&quot;,
  437. but excludes all &quot;*.gif&quot; files from the copy.</p>
  438. <h3>Default Excludes</h3>
  439. <p>There are a set of definitions which are excluded by default from all directory based tasks.
  440. They are:
  441. <pre> &quot;**/*~&quot;,
  442. &quot;**/#*#&quot;,
  443. &quot;**/%*%&quot;,
  444. &quot;**/CVS&quot;,
  445. &quot;**/CVS/*&quot;,
  446. &quot;**/.cvsignore&quot;
  447. </pre>
  448. If you do not want these default excludes applied, you may disable them with the
  449. <code>defaultexcludes=&quot;no&quot;</code> attribute.</p>
  450. <hr>
  451. <h2><a name="tasks">Built in tasks</a></h2>
  452. <ul>
  453. <li><a href="#ant">Ant</a></li>
  454. <li><a href="#available">Available</a></li>
  455. <li><a href="#chmod">Chmod</a></li>
  456. <li><a href="#copydir">Copydir</a></li>
  457. <li><a href="#copyfile">Copyfile</a></li>
  458. <li><a href="#cvs">Cvs</a></li>
  459. <li><a href="#delete">Delete</a></li>
  460. <li><a href="#deltree">Deltree</a></li>
  461. <li><a href="#echo">Echo</a></li>
  462. <li><a href="#exec">Exec</a></li>
  463. <li><a href="#expand">Expand</a></li>
  464. <li><a href="#filter">Filter</a></li>
  465. <li><a href="#get">Get</a></li>
  466. <li><a href="#gunzip">GUnzip</a></li>
  467. <li><a href="#gzip">GZip</a></li>
  468. <li><a href="#fixcrlf">FixCRLF</a></li>
  469. <li><a href="#jar">Jar</a></li>
  470. <li><a href="#java">Java</a></li>
  471. <li><a href="#javac">Javac</a></li>
  472. <li><a href="#javadoc">Javadoc/Javadoc2</a></li>
  473. <li><a href="#keysubst">KeySubst</a></li>
  474. <li><a href="#mkdir">Mkdir</a></li>
  475. <li><a href="#property">Property</a></li>
  476. <li><a href="#rename">Rename</a></li>
  477. <li><a href="#replace">Replace</a></li>
  478. <li><a href="#rmic">Rmic</a></li>
  479. <li><a href="#tar">Tar</a></li>
  480. <li><a href="#taskdef">Taskdef</a></li>
  481. <li><a href="#tstamp">Tstamp</a></li>
  482. <li><a href="#untar">Untar</a></li>
  483. <li><a href="#zip">Zip</a></li>
  484. </ul>
  485. <hr>
  486. <h2><a name="ant">Ant</a></h2>
  487. <h3><b>Description:</b></h3>
  488. <p>Runs Ant on a supplied buildfile. This can be used to build subprojects.</p>
  489. <p>When the <i>antfile</i> attribute is omitted, the file &quot;build.xml&quot;
  490. in the supplied directory (<i>dir</i> attribute) is used.</p>
  491. <p>If no target attribute is supplied, the default target of the new project is
  492. used.</p>
  493. <p>The properties of the current project will be available in the new project.
  494. These properties will override the properties that are set in the new project.
  495. (See also the <a href="#property">properties task</a>).</p>
  496. <h3>Parameters:</h3>
  497. <table border="1" cellpadding="2" cellspacing="0">
  498. <tr>
  499. <td valign="top"><b>Attribute</b></td>
  500. <td valign="top"><b>Description</b></td>
  501. <td align="center" valign="top"><b>Required</b></td>
  502. </tr>
  503. <tr>
  504. <td valign="top">antfile</td>
  505. <td valign="top">the buildfile to use.</td>
  506. <td valign="top" align="center">No</td>
  507. </tr>
  508. <tr>
  509. <td valign="top">dir</td>
  510. <td valign="top">the directory to use as a basedir for the new Ant project.</td>
  511. <td valign="top" align="center">Yes</td>
  512. </tr>
  513. <tr>
  514. <td valign="top">target</td>
  515. <td valign="top">the target of the new Ant project that should be executed.</td>
  516. <td valign="top" align="center">No</td>
  517. </tr>
  518. </table>
  519. <h3>Examples</h3>
  520. <blockquote>
  521. <p><code>&lt;ant antfile=&quot;subproject/subbuild.xml&quot; dir=&quot;subproject&quot;
  522. target=&quot;compile&quot; /&gt;</code></p>
  523. <p><code>&lt;ant dir=&quot;subproject&quot; /&gt;</code></p>
  524. </blockquote>
  525. <hr>
  526. <h2><a name="available">Available</a></h2>
  527. <h3>Description</h3>
  528. <p>Sets a property if a resource is available at runtime. This resource can be a
  529. file resource, a class in classpath or a JVM system resource.</p>
  530. <p>The value part of the properties being set is <i>true</i> if the resource is
  531. present, otherwise, the property is not set.</p>
  532. <p>Normally, this task is used to set properties that are useful to avoid target
  533. execution depending on system parameters.</p>
  534. <h3>Parameters</h3>
  535. <table border="1" cellpadding="2" cellspacing="0">
  536. <tr>
  537. <td valign="top"><b>Attribute</b></td>
  538. <td valign="top"><b>Description</b></td>
  539. <td align="center" valign="top"><b>Required</b></td>
  540. </tr>
  541. <tr>
  542. <td valign="top">property</td>
  543. <td valign="top">the name of the property to set.</td>
  544. <td valign="top" align="center">Yes</td>
  545. </tr>
  546. <tr>
  547. <td valign="top">classname</td>
  548. <td valign="top">the class to look for in classpath.</td>
  549. <td valign="middle" align="center" rowspan="3">Yes</td>
  550. </tr>
  551. <tr>
  552. <td valign="top">resource</td>
  553. <td valign="top">the resource to look for in the JVM</td>
  554. </tr>
  555. <tr>
  556. <td valign="top">file</td>
  557. <td valign="top">the file to look for.</td>
  558. </tr>
  559. </table>
  560. <h3>Examples</h3>
  561. <pre> &lt;available classname=&quot;org.whatever.Myclass&quot; property=&quot;Myclass.present&quot; /&gt;</pre>
  562. <p>sets the property <code><i>Myclass.present</i></code> to the value &quot;true&quot;
  563. if the <i>org.whatever.Myclass</i> is found in Ant's classpath.</p>
  564. <hr>
  565. <h2><a name="chmod">Chmod</a></h2>
  566. <h3>Description</h3>
  567. <p>Changes the permissions of a file. Right now it has efect only under Unix.
  568. The permissions are also UNIX style, like the argument for the chmod command.</p>
  569. <h3>Parameters</h3>
  570. <table border="1" cellpadding="2" cellspacing="0">
  571. <tr>
  572. <td valign="top"><b>Attribute</b></td>
  573. <td valign="top"><b>Description</b></td>
  574. <td align="center" valign="top"><b>Required</b></td>
  575. </tr>
  576. <tr>
  577. <td valign="top">src</td>
  578. <td valign="top">the file of which the permissions must be changed.</td>
  579. <td valign="top" align="center">Yes</td>
  580. </tr>
  581. <tr>
  582. <td valign="top">perm</td>
  583. <td valign="top">the new permissions.</td>
  584. <td valign="top" align="center">Yes</td>
  585. </tr>
  586. </table>
  587. <h3>Examples</h3>
  588. <blockquote>
  589. <p><code>&lt;chmod src=&quot;${dist}/start.sh&quot; perm=&quot;ugo+rx&quot;
  590. /&gt;</code></p>
  591. </blockquote>
  592. <p>makes the &quot;start.sh&quot; file readable and executable for anyone on a
  593. UNIX system.</p>
  594. <hr>
  595. <h2><a name="copydir">Copydir</a></h2>
  596. <h3>Description</h3>
  597. <p>Copies a directory tree from the source to the destination.</p>
  598. <p>It is possible to refine the set of files that are being copied. This can be
  599. done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  600. attributes. With the <i>includes</i> attribute you specify the files you want to
  601. have included by using patterns. The <i>exclude</i> attribute is used to specify
  602. the files you want to have excluded. This is also done with patterns. And
  603. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  604. want to use default exclusions or not. See the section on <a
  605. href="#directorybasedtasks">directory based tasks</a>, on how the
  606. inclusion/exclusion of files works, and how to write patterns. The patterns are
  607. relative to the <i>src</i> directory.</p>
  608. <p>The <i>ignore</i> attribute contains the names of the files/directories that
  609. must be excluded from the copy. The names specified in the <i>ignore</i>
  610. attribute are just names, they do not contain any path information! Note that
  611. this attribute has been replaced by the <i>excludes</i> attribute.</p>
  612. <h3>Parameters</h3>
  613. <table border="1" cellpadding="2" cellspacing="0">
  614. <tr>
  615. <td valign="top"><b>Attribute</b></td>
  616. <td valign="top"><b>Description</b></td>
  617. <td align="center" valign="top"><b>Required</b></td>
  618. </tr>
  619. <tr>
  620. <td valign="top">src</td>
  621. <td valign="top">the directory to copy.</td>
  622. <td valign="top" align="center">Yes</td>
  623. </tr>
  624. <tr>
  625. <td valign="top">dest</td>
  626. <td valign="top">the directory to copy to.</td>
  627. <td valign="top" align="center">Yes</td>
  628. </tr>
  629. <tr>
  630. <td valign="top">ignore</td>
  631. <td valign="top">comma separated list of filenames/directorynames to ignore.
  632. No files (except default excludes) are excluded when omitted. (<b>deprecated</b>,
  633. use <i>excludes</i> instead).</td>
  634. <td valign="top" align="center">No</td>
  635. </tr>
  636. <tr>
  637. <td valign="top">includes</td>
  638. <td valign="top">comma separated list of patterns of files that must be
  639. included. All files are included when omitted.</td>
  640. <td valign="top" align="center">No</td>
  641. </tr>
  642. <tr>
  643. <td valign="top">excludes</td>
  644. <td valign="top">comma separated list of patterns of files that must be
  645. excluded. No files (except default excludes) are excluded when omitted.</td>
  646. <td valign="top" align="center">No</td>
  647. </tr>
  648. <tr>
  649. <td valign="top">defaultexcludes</td>
  650. <td valign="top">indicates whether default excludes should be used or not
  651. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  652. <td valign="top" align="center">No</td>
  653. </tr>
  654. <tr>
  655. <td valign="top">filtering</td>
  656. <td valign="top">indicates whether token filtering should take place during
  657. the copy</td>
  658. <td valign="top" align="center">No</td>
  659. </tr>
  660. </table>
  661. <h3>Examples</h3>
  662. <pre> &lt;copydir src=&quot;${src}/resources&quot;
  663. dest=&quot;${dist}&quot;
  664. /&gt;</pre>
  665. <p>copies the directory <code>${src}/resources</code> to <code>${dist}</code>.</p>
  666. <pre> &lt;copydir src=&quot;${src}/resources&quot;
  667. dest=&quot;${dist}&quot;
  668. includes=&quot;**/*.java&quot;
  669. excludes=&quot;**/Test.java&quot;
  670. /&gt;</pre>
  671. <p>copies the directory <code>${src}/resources</code> to <code>${dist}</code>
  672. recursively. All java files are copied, except for files with the name <code>Test.java</code>.</p>
  673. <pre> &lt;copydir src=&quot;${src}/resources&quot;
  674. dest=&quot;${dist}&quot;
  675. includes=&quot;**/*.java&quot;
  676. excludes=&quot;mypackage/test/**&quot; /&gt;</pre>
  677. <p>copies the directory <code>${src}/resources</code> to <code>${dist}</code>
  678. recursively. All java files are copied, except for the files under the <code>mypackage/test</code>
  679. directory.</p>
  680. <hr>
  681. <h2><a name="copyfile">Copyfile</a></h2>
  682. <h3>Description</h3>
  683. <p>Copies a file from the source to the destination. The file is only copied if
  684. the source file is newer than the destination file, or when the destination file
  685. does not exist.</p>
  686. <h3>Parameters</h3>
  687. <table border="1" cellpadding="2" cellspacing="0">
  688. <tr>
  689. <td valign="top"><b>Attribute</b></td>
  690. <td valign="top"><b>Description</b></td>
  691. <td align="center" valign="top"><b>Required</b></td>
  692. </tr>
  693. <tr>
  694. <td valign="top">src</td>
  695. <td valign="top">the filename of the file to copy.</td>
  696. <td valign="top" align="center">Yes</td>
  697. </tr>
  698. <tr>
  699. <td valign="top">dest</td>
  700. <td valign="top">the filename of the file where to copy to.</td>
  701. <td valign="top" align="center">Yes</td>
  702. </tr>
  703. <tr>
  704. <td valign="top">filtering</td>
  705. <td valign="top">indicates whether token filtering should take place during
  706. the copy</td>
  707. <td valign="top" align="center">No</td>
  708. </tr>
  709. </table>
  710. <h3>Examples</h3>
  711. <blockquote>
  712. <p><code>&lt;copyfile src=&quot;test.java&quot; dest=&quot;subdir/test.java&quot;
  713. /&gt;</code></p>
  714. <p><code>&lt;copyfile src=&quot;${src}/index.html&quot; dest=&quot;${dist}/help/index.html&quot;
  715. /&gt;</code></p>
  716. </blockquote>
  717. <hr>
  718. <h2><a name="cvs">Cvs</a></h2>
  719. <h3>Description</h3>
  720. <p>Checks out a package/module from a <a href="http://www.cyclic.com/">CVS</a>
  721. repository.</p>
  722. <p>When doing automated builds, the <a href="#get">get task</a> should be
  723. preferred, because of speed.</p>
  724. <h3>Parameters</h3>
  725. <table border="1" cellpadding="2" cellspacing="0">
  726. <tr>
  727. <td valign="top"><b>Attribute</b></td>
  728. <td valign="top"><b>Description</b></td>
  729. <td align="center" valign="top"><b>Required</b></td>
  730. </tr>
  731. <tr>
  732. <td valign="top">cvsRoot</td>
  733. <td valign="top">the CVSROOT variable.</td>
  734. <td align="center" valign="top">Yes</td>
  735. </tr>
  736. <tr>
  737. <td valign="top">dest</td>
  738. <td valign="top">the directory where the checked out files should be placed.</td>
  739. <td align="center" valign="top">Yes</td>
  740. </tr>
  741. <tr>
  742. <td valign="top">package</td>
  743. <td valign="top">the package/module to check out.</td>
  744. <td align="center" valign="top">Yes</td>
  745. </tr>
  746. <tr>
  747. <td valign="top">tag</td>
  748. <td valign="top">the tag of the package/module to check out.</td>
  749. <td align="center" valign="top">No</td>
  750. </tr>
  751. </table>
  752. <h3>Examples</h3>
  753. <pre> &lt;cvs cvsRoot=&quot;:pserver:anoncvs@jakarta.apache.org:/home/cvspublic&quot;
  754. package=&quot;jakarta-tools&quot;
  755. dest=&quot;${ws.dir}&quot;
  756. /&gt;</pre>
  757. <p>checks out the package/module &quot;jakarta-tools&quot; from the CVS
  758. repository pointed to by the cvsRoot attribute, and stores the files in &quot;${ws.dir}&quot;.</p>
  759. <hr>
  760. <td valign="top">comma separated list of filenam<h2><a name="delete">Delete</a></h2>
  761. <h3>Description</h3>
  762. <p>Deletes either a single file or
  763. all files in a specified directory and its sub-directories.</p>
  764. <p>It is possible to refine the set of files that are being deleted. This can be
  765. done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  766. attributes. With the <i>includes</i> attribute you specify the files you want to
  767. have included in the deletion process by using patterns. The <i>exclude</i> attribute is used to specify
  768. the files you want to have excluded from the deletion process. This is also done with patterns. And
  769. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  770. want to use default exclusions or not. See the section on <a
  771. href="#directorybasedtasks">directory based tasks</a>, on how the
  772. inclusion/exclusion of files works, and how to write patterns. The patterns are
  773. relative to the <i>dir</i> directory.</p>
  774. <h3>Parameters</h3>
  775. <table border="1" cellpadding="2" cellspacing="0">
  776. <tr>
  777. <td valign="top"><b>Attribute</b></td>
  778. <td valign="top"><b>Description</b></td>
  779. <td align="center" valign="top"><b>Required</b></td>
  780. </tr>
  781. <tr>
  782. <td valign="top">file</td>
  783. <td valign="top">The file to delete.</td>
  784. <td align="center" valign="middle" rowspan="2">at least one of the two</td>
  785. </tr>
  786. <tr>
  787. <td valign="top">dir</td>
  788. <td valign="top">The directory to delete files from.</td>
  789. </tr>
  790. <tr>
  791. <td valign="top">includes</td>
  792. <td valign="top">Comma separated list of patterns of files that must be
  793. deleted. All files are in the current directory
  794. and any sub-directories are deleted when omitted.</td>
  795. <td valign="top" align="center">No</td>
  796. </tr>
  797. <tr>
  798. <td valign="top">excludes</td>
  799. <td valign="top">Comma separated list of patterns of files that must be
  800. excluded from the deletion list. No files (except default excludes) are excluded when omitted.</td>
  801. <td valign="top" align="center">No</td>
  802. </tr>
  803. <tr>
  804. <td valign="top">defaultexcludes</td>
  805. <td valign="top">Indicates whether default excludes should be used or not
  806. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  807. <td valign="top" align="center">No</td>
  808. </tr>
  809. <tr>
  810. <td valign="top">verbose</td>
  811. <td valign="top">Show name of each deleted file (&quot;true&quot;/&quot;false&quot;). Default is "false" when omitted.</td>
  812. <td align="center" valign="top">No</td>
  813. </tr>
  814. </table>
  815. <h3>Examples</h3>
  816. <pre> &lt;delete file=&quot;/lib/ant.jar&quot; /&gt;</pre>
  817. <p>deletes the file <code>/lib/ant.jar</code>.</p>
  818. <pre> &lt;delete dir=&quot;lib&quot; /&gt;</pre>
  819. <p>deletes all files in the <code>/lib</code> directory.</p>
  820. <pre> &lt;delete dir=&quot;.&quot;
  821. include=&quot;**/*.bak&quot;
  822. /&gt;
  823. </pre>
  824. <p>deletes all files with the extension &quot;<code>.bak</code>&quot from the current directory
  825. and any sub-directories.</p>
  826. <h2><a name="deltree">Deltree</a></h2>
  827. <h3>Description</h3>
  828. <p>Deletes a directory with all its files and subdirectories.</p>
  829. <h3>Parameters</h3>
  830. <table border="1" cellpadding="2" cellspacing="0">
  831. <tr>
  832. <td valign="top"><b>Attribute</b></td>
  833. <td valign="top"><b>Description</b></td>
  834. <td align="center" valign="top"><b>Required</b></td>
  835. </tr>
  836. <tr>
  837. <td valign="top">dir</td>
  838. <td valign="top">the directory to delete.</td>
  839. <td valign="top" align="center">Yes</td>
  840. </tr>
  841. </table>
  842. <h3>Examples</h3>
  843. <pre> &lt;deltree dir=&quot;dist&quot; /&gt;</pre>
  844. <p>deletes the directory <code>dist</code>, including its files and
  845. subdirectories.</p>
  846. <pre> &lt;deltree dir=&quot;${dist}&quot; /&gt;</pre>
  847. <p>deletes the directory <code>${dist}</code>, including its files and
  848. subdirectories.</p>
  849. <hr>
  850. <h2><a name="echo">Echo</a></h2>
  851. <h3>Description</h3>
  852. <p>Echoes a message to System.out.</p>
  853. <h3>Parameters</h3>
  854. <table border="1" cellpadding="2" cellspacing="0">
  855. <tr>
  856. <td valign="top"><b>Attribute</b></td>
  857. <td valign="top"><b>Description</b></td>
  858. <td align="center" valign="top"><b>Required</b></td>
  859. </tr>
  860. <tr>
  861. <td valign="top">message</td>
  862. <td valign="top">the message to echo.</td>
  863. <td valign="top" align="center">Yes</td>
  864. </tr>
  865. </table>
  866. <h3>Examples</h3>
  867. <pre> &lt;echo message=&quot;Hello world&quot; /&gt;</pre>
  868. <hr>
  869. <h2><a name="exec">Exec</a></h2>
  870. <h3>Description</h3>
  871. <p>Executes a system command. When the <i>os</i> attribute is specified, then
  872. the command is only executed when Ant is run on one of the specified operating
  873. systems.</p>
  874. <h3>Parameters</h3>
  875. <table border="1" cellpadding="2" cellspacing="0">
  876. <tr>
  877. <td valign="top"><b>Attribute</b></td>
  878. <td valign="top"><b>Description</b></td>
  879. <td align="center" valign="top"><b>Required</b></td>
  880. </tr>
  881. <tr>
  882. <td valign="top">command</td>
  883. <td valign="top">the command to execute.</td>
  884. <td align="center" valign="top">Yes</td>
  885. </tr>
  886. <tr>
  887. <td valign="top">dir</td>
  888. <td valign="top">the directory in which the command should be executed.</td>
  889. <td align="center" valign="top">Yes</td>
  890. </tr>
  891. <tr>
  892. <td valign="top">os</td>
  893. <td valign="top">list of Operating Systems on which the command may be
  894. executed.</td>
  895. <td align="center" valign="top">No</td>
  896. </tr>
  897. <tr>
  898. <td valign="top">output</td>
  899. <td valign="top">the file to which the output of the command should be
  900. redirected.</td>
  901. <td align="center" valign="top">Yes</td>
  902. </tr>
  903. </table>
  904. <h3>Examples</h3>
  905. <blockquote>
  906. <p><code>&lt;exec dir=&quot;${src}&quot; command=&quot;dir&quot; os=&quot;windows&quot;
  907. output=&quot;dir.txt&quot; /&gt;</code></p>
  908. </blockquote>
  909. <hr>
  910. <h2><a name="expand">Expand</a></h2>
  911. <h3>Description</h3>
  912. <p>Unzips a zipfile.</p>
  913. <h3>Parameters</h3>
  914. <table border="1" cellpadding="2" cellspacing="0">
  915. <tr>
  916. <td valign="top"><b>Attribute</b></td>
  917. <td valign="top"><b>Description</b></td>
  918. <td align="center" valign="top"><b>Required</b></td>
  919. </tr>
  920. <tr>
  921. <td valign="top">src</td>
  922. <td valign="top">zipfile to expand.</td>
  923. <td align="center" valign="top">Yes</td>
  924. </tr>
  925. <tr>
  926. <td valign="top">dest</td>
  927. <td valign="top">directory where to store the expanded files.</td>
  928. <td align="center" valign="top">Yes</td>
  929. </tr>
  930. </table>
  931. <h3>Examples</h3>
  932. <blockquote>
  933. <p><code>&lt;expand src=&quot;${tomcat_src}/tools-src.zip&quot; dest=&quot;${tools.home}&quot;
  934. /&gt;</code></p>
  935. </blockquote>
  936. <hr>
  937. <h2><a name="filter">Filter</a></h2>
  938. <h3>Description</h3>
  939. <p>Sets a token filter for this project. Token filters are used by all tasks
  940. that perform file copying operations through the Project commodity methods.</p>
  941. <p>Note: the token string must not contain the separators chars (@).</p>
  942. <h3>Parameters</h3>
  943. <table border="1" cellpadding="2" cellspacing="0">
  944. <tr>
  945. <td valign="top"><b>Attribute</b></td>
  946. <td valign="top"><b>Description</b></td>
  947. <td align="center" valign="top"><b>Required</b></td>
  948. </tr>
  949. <tr>
  950. <td valign="top">token</td>
  951. <td valign="top">the token string without @</td>
  952. <td align="center" valign="top">Yes</td>
  953. </tr>
  954. <tr>
  955. <td valign="top">value</td>
  956. <td valign="top">the string that should be put to replace the token when the
  957. file is copied</td>
  958. <td align="center" valign="top">Yes</td>
  959. </tr>
  960. </table>
  961. <h3>Examples</h3>
  962. <pre> &lt;filter token=&quot;year&quot; value=&quot;2000&quot; /&gt;
  963. &lt;copydir src=&quot;${src.dir}&quot; dest=&quot;${dest.dir}&quot;/&gt;</pre>
  964. <p>will copy recursively all the files from the <i>src.dir</i> directory into
  965. the <i>dest.dir</i> directory replacing all the occurencies of the string <i>@year@</i>
  966. with <i>2000.</i></p>
  967. <hr>
  968. <h2><a name="get">Get</a></h2>
  969. <h3>Description</h3>
  970. <p>Gets a file from an URL. When the verbose option is &quot;on&quot;, this task
  971. displays a '.' for every 100 Kb retrieved.</p>
  972. <p>This task should be preferred above the <a href="#cvs">CVS task</a> when
  973. doing automated builds. CVS is significant slower than loading a compressed
  974. archive with http/ftp.</p>
  975. <h3>Parameters</h3>
  976. <table border="1" cellpadding="2" cellspacing="0">
  977. <tr>
  978. <td valign="top"><b>Attribute</b></td>
  979. <td valign="top"><b>Description</b></td>
  980. <td align="center" valign="top"><b>Required</b></td>
  981. </tr>
  982. <tr>
  983. <td valign="top">src</td>
  984. <td valign="top">the URL from which to retrieve a file.</td>
  985. <td align="center" valign="top">Yes</td>
  986. </tr>
  987. <tr>
  988. <td valign="top">dest</td>
  989. <td valign="top">the file where to store the retrieved file.</td>
  990. <td align="center" valign="top">Yes</td>
  991. </tr>
  992. <tr>
  993. <td valign="top">verbose</td>
  994. <td valign="top">show verbose information (&quot;on&quot;/&quot;off&quot;).</td>
  995. <td align="center" valign="top">No</td>
  996. </tr>
  997. </table>
  998. <h3>Examples</h3>
  999. <pre> &lt;get src=&quot;http://jakarta.apache.org/&quot; dest=&quot;help/index.html&quot; /&gt;</pre>
  1000. <p>gets the index page of http://jakarta.apache.org/, and stores it in the file <code>help/index.html</code>.</p>
  1001. <hr>
  1002. <h2><a name="gunzip">GUnzip</a></h2>
  1003. <h3>Description</h3>
  1004. <p>Expands a GZip file.</p>
  1005. <p>If <i>dest</i> is a directory the name of the destination file is
  1006. the same as <i>src</i> (with the &quot;.gz&quot; extension removed if
  1007. present). If <i>dest</i> is ommited, the parent dir of <i>src</i> is
  1008. taken. The file is only expanded if the source file is newer than the
  1009. destination file, or when the destination file does not exist.</p>
  1010. <h3>Parameters</h3>
  1011. <table border="1" cellpadding="2" cellspacing="0">
  1012. <tr>
  1013. <td valign="top"><b>Attribute</b></td>
  1014. <td valign="top"><b>Description</b></td>
  1015. <td align="center" valign="top"><b>Required</b></td>
  1016. </tr>
  1017. <tr>
  1018. <td valign="top">src</td>
  1019. <td valign="top">the file to expand.</td>
  1020. <td align="center" valign="top">Yes</td>
  1021. </tr>
  1022. <tr>
  1023. <td valign="top">dest</td>
  1024. <td valign="top">the destination file or directory.</td>
  1025. <td align="center" valign="top">No</td>
  1026. </tr>
  1027. </table>
  1028. <h3>Examples</h3>
  1029. <blockquote>
  1030. <p><code>&lt;gunzip src=&quot;test.tar.gz&quot;/&gt;</code></p>
  1031. </blockquote>
  1032. <p>expands <i>test.tar.gz</i> to <i>test.tar</i></p>
  1033. <blockquote>
  1034. <p><code>&lt;gunzip src=&quot;test.tar.gz&quot; dest=&quot;test2.tar&quot;/&gt;</code></p>
  1035. </blockquote>
  1036. <p>expands <i>test.tar.gz</i> to <i>test2.tar</i></p>
  1037. <blockquote>
  1038. <p><code>&lt;gunzip src=&quot;test.tar.gz&quot; dest=&quot;subdir&quot;/&gt;</code></p>
  1039. </blockquote>
  1040. <p>expands <i>test.tar.gz</i> to <i>subdir/test.tar</i> (assuming
  1041. subdir is a directory).</p>
  1042. <hr>
  1043. <h2><a name="gzip">GZip</a></h2>
  1044. <h3>Description</h3>
  1045. <p>GZips a file.</p>
  1046. <h3>Parameters</h3>
  1047. <table border="1" cellpadding="2" cellspacing="0">
  1048. <tr>
  1049. <td valign="top"><b>Attribute</b></td>
  1050. <td valign="top"><b>Description</b></td>
  1051. <td align="center" valign="top"><b>Required</b></td>
  1052. </tr>
  1053. <tr>
  1054. <td valign="top">src</td>
  1055. <td valign="top">the file to gzip.</td>
  1056. <td align="center" valign="top">Yes</td>
  1057. </tr>
  1058. <tr>
  1059. <td valign="top">zipfile</td>
  1060. <td valign="top">the destination file.</td>
  1061. <td align="center" valign="top">Yes</td>
  1062. </tr>
  1063. </table>
  1064. <h3>Examples</h3>
  1065. <blockquote>
  1066. <p><code>&lt;gzip src=&quot;test.tar&quot; zipfile=&quot;test.tar.gz&quot;
  1067. /&gt;</code></p>
  1068. </blockquote>
  1069. <hr>
  1070. <h2><a name="fixcrlf">FixCRLF</a></h2>
  1071. <h3>Description</h3>
  1072. <p>Adjusts a text file to local.</p>
  1073. <p>The <i>basedir</i> attribute is the reference directory from where to jar.</p>
  1074. <h3>Parameters</h3>
  1075. <table border="1" cellpadding="2" cellspacing="0">
  1076. <tr>
  1077. <td valign="top"><b>Attribute</b></td>
  1078. <td valign="top"><b>Description</b></td>
  1079. <td align="center" valign="top"><b>Required</b></td>
  1080. </tr>
  1081. <tr>
  1082. <td valign="top">srcDir</td>
  1083. <td valign="top">Where to find the files to be fixed up.</td>
  1084. <td valign="top" align="center">Yes</td>
  1085. </tr>
  1086. <tr>
  1087. <td valign="top">destDir</td>
  1088. <td valign="top">Where to place the corrected files. Defaults to
  1089. srcDir (replacing the original file)</td>
  1090. <td valign="top" align="center">No</td>
  1091. </tr>
  1092. <tr>
  1093. <td valign="top">includes</td>
  1094. <td valign="top">comma separated list of patterns of files that must be
  1095. included. All files are included when omitted.</td>
  1096. <td valign="top" align="center">No</td>
  1097. </tr>
  1098. <tr>
  1099. <td valign="top">excludes</td>
  1100. <td valign="top">comma separated list of patterns of files that must be
  1101. excluded. No files (except default excludes) are excluded when omitted.</td>
  1102. <td valign="top" align="center">No</td>
  1103. </tr>
  1104. <tr>
  1105. <td valign="top">cr</td>
  1106. <td valign="top">Specifies how carriage return (CR) characters are to
  1107. be handled. Valid values for this property are:
  1108. <ul>
  1109. <li>add: ensure that there is a CR before every LF
  1110. <li>asis: leave CR characters alone
  1111. <li>remove: remove all CR characters
  1112. </ul>
  1113. Default is based on the platform on which you are running this task.
  1114. For Unix platforms, the default is remove. For DOS based systems
  1115. (including Windows), the default is add.
  1116. <p>
  1117. Note: Unless this property is specified as "asis", extra CR characters
  1118. which do not preceed a LF will be removed.
  1119. </td>
  1120. <td valign="top" align="center">No</td>
  1121. </tr>
  1122. <tr>
  1123. <td valign="top">tab</td>
  1124. <td valign="top">Specifies how tab characters are to be handled. Valid
  1125. values for this property are:
  1126. <ul>
  1127. <li>add: convert sequences of spaces which span a tab stop to tabs
  1128. <li>asis: leave tab and space characters alone
  1129. <li>remove: convert tabs to spaces
  1130. </ul>
  1131. Default for this parameter is "asis".
  1132. <p>
  1133. Note: Unless this property is specified as "asis", extra spaces and
  1134. tabs after the last non-whitespace character on the line will be removed.
  1135. </td>
  1136. <td valign="top" align="center">No</td>
  1137. </tr>
  1138. <tr>
  1139. <td valign="top">eof</td>
  1140. <td valign="top">Specifies how DOS end of file (control-Z) characters are
  1141. to be handled. Valid values for this property are:
  1142. <ul>
  1143. <li>add: ensure that there is an EOF character at the end of the file
  1144. <li>asis: leave EOF characters alone
  1145. <li>remove: remove any EOF character found at the end
  1146. </ul>
  1147. Default is based on the platform on which you are running this task.
  1148. For Unix platforms, the default is remove. For DOS based systems
  1149. (including Windows), the default is asis.
  1150. </td>
  1151. <td valign="top" align="center">No</td>
  1152. </tr>
  1153. </table>
  1154. <h3>Examples</h3>
  1155. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  1156. cr=&quot;remove&quot; eof=&quot;remove&quot;
  1157. includes=&quot;**/*.sh&quot;
  1158. /&gt;</pre>
  1159. <p>Removes carriage return and eof characters from the shell scripts. Tabs and
  1160. spaces are left as is.
  1161. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  1162. cr=&quot;add&quot;
  1163. includes=&quot;**/*.bat&quot;
  1164. /&gt;</pre>
  1165. <p>Ensures that there are carriage return characters prior to evey line feed.
  1166. Tabs and spaces are left as is.
  1167. EOF characters are left alone if run on
  1168. DOS systems, and are removed if run on Unix systems.</p>
  1169. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  1170. tabs=&quot;add&quot;
  1171. includes=&quot;**/Makefile&quot;
  1172. /&gt;</pre>
  1173. <p>Adds or removes CR characters to match local OS conventions, and
  1174. converts spaces to tabs when appropriate. EOF characters are left alone if
  1175. run on DOS systems, and are removed if run on Unix systems.
  1176. Many versions of make require tabs prior to commands.</p>
  1177. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  1178. tabs=&quot;remove&quot;
  1179. includes=&quot;**/README*&quot;
  1180. /&gt;</pre>
  1181. <p>Adds or removes CR characters to match local OS conventions, and
  1182. converts all tabs to spaces. EOF characters are left alone if run on
  1183. DOS systems, and are removed if run on Unix systems.
  1184. You never know what editor a user will use to browse README's.</p>
  1185. <hr>
  1186. <h2><a name="jar">Jar</a></h2>
  1187. <h3>Description</h3>
  1188. <p>Jars a set of files.</p>
  1189. <p>The <i>basedir</i> attribute is the reference directory from where to jar.</p>
  1190. <p>It is possible to refine the set of files that are being jarred. This can be
  1191. done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  1192. attributes. With the <i>includes</i> attribute you specify the files you want to
  1193. have included by using patterns. The <i>exclude</i> attribute is used to specify
  1194. the files you want to have excluded. This is also done with patterns. And
  1195. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  1196. want to use default exclusions or not. See the section on <a
  1197. href="#directorybasedtasks">directory based tasks</a>, on how the
  1198. inclusion/exclusion of files works, and how to write patterns. The patterns are
  1199. relative to the <i>basedir</i> directory.</p>
  1200. <p>The <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i> attributes
  1201. replace the <i>items</i> and <i>ignore</i> attributes. The following explains
  1202. how the deprecated <i>items</i> and <i>ignore</i> attribute behave.</p>
  1203. <p>When &quot;*&quot; is used for <i>items</i>, all files in the basedir, and
  1204. its subdirectories, will be jarred. Otherwise all the files and directories
  1205. mentioned in the items list will jarred. When a directory is specified, then all
  1206. files within it are also jarred.</p>
  1207. <p>With the <i>ignore</i> attribute, you can specify files or directories to
  1208. ignore. These files will not be jarred. The items in the <i>ignore</i> attribute
  1209. override the items in the <i>items</i> attribute. The names specified in the <i>ignore</i>
  1210. attribute are just names, they do not contain any path information!</p>
  1211. <h3>Parameters</h3>
  1212. <table border="1" cellpadding="2" cellspacing="0">
  1213. <tr>
  1214. <td valign="top"><b>Attribute</b></td>
  1215. <td valign="top"><b>Description</b></td>
  1216. <td align="center" valign="top"><b>Required</b></td>
  1217. </tr>
  1218. <tr>
  1219. <td valign="top">jarfile</td>
  1220. <td valign="top">the jar-file to create.</td>
  1221. <td valign="top" align="center">Yes</td>
  1222. </tr>
  1223. <tr>
  1224. <td valign="top">basedir</td>
  1225. <td valign="top">the directory from which to jar the files.</td>
  1226. <td valign="top" align="center">Yes</td>
  1227. </tr>
  1228. <tr>
  1229. <td valign="top">compress</td>
  1230. <td valign="top">Not only store data but also compress them, defaults to true</td>
  1231. <td align="center" valign="top">No</td>
  1232. </tr>
  1233. <tr>
  1234. <td valign="top">items</td>
  1235. <td valign="top">a comma separated list of the files/directories to jar. All
  1236. files are included when omitted. (<b>deprecated</b>, use <i>includes</i>
  1237. instead).</td>
  1238. <td valign="top" align="center">No</td>
  1239. </tr>
  1240. <tr>
  1241. <td valign="top">ignore</td>
  1242. <td valign="top">comma separated list of filenames/directorynames to exclude
  1243. from the jar. No files (except default excludes) are excluded when
  1244. omitted. (<b>deprecated</b>, use <i>excludes</i> instead).</td>
  1245. <td valign="top" align="center">No</td>
  1246. </tr>
  1247. <tr>
  1248. <td valign="top">includes</td>
  1249. <td valign="top">comma separated list of patterns of files that must be
  1250. included. All files are included when omitted.</td>
  1251. <td valign="top" align="center">No</td>
  1252. </tr>
  1253. <tr>
  1254. <td valign="top">excludes</td>
  1255. <td valign="top">comma separated list of patterns of files that must be
  1256. excluded. No files (except default excludes) are excluded when omitted.</td>
  1257. <td valign="top" align="center">No</td>
  1258. </tr>
  1259. <tr>
  1260. <td valign="top">defaultexcludes</td>
  1261. <td valign="top">indicates whether default excludes should be used or not
  1262. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  1263. <td valign="top" align="center">No</td>
  1264. </tr>
  1265. <tr>
  1266. <td valign="top">manifest</td>
  1267. <td valign="top">the manifest file to use.</td>
  1268. <td valign="top" align="center">No</td>
  1269. </tr>
  1270. </table>
  1271. <h3>Examples</h3>
  1272. <pre> &lt;jar jarfile=&quot;${dist}/lib/app.jar&quot; basedir=&quot;${build}/classes&quot; /&gt;</pre>
  1273. <p>jars all files in the <code>${build}/classes</code> directory in a file
  1274. called <code>app.jar</code> in the <code>${dist}/lib</code> directory.</p>
  1275. <pre> &lt;jar jarfile=&quot;${dist}/lib/app.jar&quot;
  1276. basedir=&quot;${build}/classes&quot;
  1277. excludes=&quot;**/Test.class&quot;
  1278. /&gt;</pre>
  1279. <p>jars all files in the <code>${build}/classes</code> directory in a file
  1280. called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Files
  1281. with the name <code>Test.class</code> are excluded.</p>
  1282. <pre> &lt;jar jarfile=&quot;${dist}/lib/app.jar&quot;
  1283. basedir=&quot;${build}/classes&quot;
  1284. includes=&quot;mypackage/test/**&quot;
  1285. excludes=&quot;**/Test.class&quot;
  1286. /&gt;</pre>
  1287. <p>jars all files in the <code>${build}/classes</code> directory in a file
  1288. called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Only
  1289. files under the directory <code>mypackage/test</code> are used, and files with
  1290. the name <code>Test.class</code> are excluded.</p>
  1291. <h3>Deprecated examples</h3>
  1292. <pre> &lt;jar jarfile=&quot;${dist}/lib/app.jar&quot; basedir=&quot;${build}/classes&quot; items=&quot;*&quot; /&gt;</pre>
  1293. <p>jars all files in the <code>${build}/classes</code> directory in a file
  1294. called <code>app.jar</code> in the <code>${dist}/lib</code> directory.</p>
  1295. <pre> &lt;jar jarfile=&quot;${dist}/lib/app.jar&quot; basedir=&quot;${build}/classes&quot; items=&quot;*&quot; ignore=&quot;Test.class&quot; /&gt;</pre>
  1296. <p>jars all files in the <code>${build}/classes</code> directory in a file
  1297. called <code>app.jar</code> in the <code>${dist}/lib</code> directory.
  1298. Files/directories with the name <code>Test.class</code> are excluded.</p>
  1299. <hr>
  1300. <h2><a name="java">Java</a></h2>
  1301. <h3>Description</h3>
  1302. <p>Executes a Java class within the running (Ant) VM or forks another VM if
  1303. specified.</p>
  1304. <p>Be careful that the executed class doesn't call System.exit(), because it
  1305. will terminate the VM and thus Ant. In case this happens, it's highly suggested
  1306. that you set the fork attribute so that System.exit() stops the other VM and not
  1307. the one that is currently running Ant.</p>
  1308. <h3>Parameters</h3>
  1309. <table border="1" cellpadding="2" cellspacing="0">
  1310. <tr>
  1311. <td valign="top"><b>Attribute</b></td>
  1312. <td valign="top"><b>Description</b></td>
  1313. <td align="center" valign="top"><b>Required</b></td>
  1314. </tr>
  1315. <tr>
  1316. <td valign="top">classname</td>
  1317. <td valign="top">the Java class to execute.</td>
  1318. <td align="center" valign="top">Yes</td>
  1319. </tr>
  1320. <tr>
  1321. <td valign="top">args</td>
  1322. <td valign="top">the arguments for the class that is executed.</td>
  1323. <td align="center" valign="top">No</td>
  1324. </tr>
  1325. <tr>
  1326. <td valign="top">fork</td>
  1327. <td valign="top">if enabled triggers the class execution in another VM
  1328. (disabled by default)</td>
  1329. <td align="center" valign="top">No</td>
  1330. </tr>
  1331. <tr>
  1332. <td valign="top">jvmargs</td>
  1333. <td valign="top">the arguments to pass to the forked VM (ignored if fork is
  1334. disabled)</td>
  1335. <td align="center" valign="top">No</td>
  1336. </tr>
  1337. </table>
  1338. <h3>Examples</h3>
  1339. <pre> &lt;java classname=&quot;test.Main&quot; /&gt;</pre>
  1340. <pre> &lt;java classname=&quot;test.Main&quot; args=&quot;-h&quot; /&gt;</pre>
  1341. <pre> &lt;java classname=&quot;test.Main&quot;
  1342. args=&quot;-h&quot;
  1343. fork=&quot;yes&quot;
  1344. jvmargs=&quot;-Xrunhprof:cpu=samples,file=log.txt,depth=3&quot;
  1345. /&gt;</pre>
  1346. <hr>
  1347. <h2><a name="javac">Javac</a></h2>
  1348. <h3>Description</h3>
  1349. <p>Compiles a source tree within the running (Ant) VM.</p>
  1350. <p>The source and destination directory will be recursively scanned for Java
  1351. source files to compile. Only Java files that have no corresponding class file
  1352. or where the class file is older than the java file will be compiled.</p>
  1353. <p>Files in the source tree, that are no java files, are copied to the
  1354. destination directory, allowing support files to be located properly in the
  1355. classpath.</p>
  1356. <p>The directory structure of the source tree should follow the package
  1357. hierarchy.</p>
  1358. <p>It is possible to refine the set of files that are being compiled/copied.
  1359. This can be done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  1360. attributes. With the <i>includes</i> attribute you specify the files you want to
  1361. have included by using patterns. The <i>exclude</i> attribute is used to specify
  1362. the files you want to have excluded. This is also done with patterns. And
  1363. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  1364. want to use default exclusions or not. See the section on <a
  1365. href="#directorybasedtasks">directory based tasks</a>, on how the
  1366. inclusion/exclusion of files works, and how to write patterns. The patterns are
  1367. relative to the <i>srcdir</i> directory.</p>
  1368. <p>It is possible to use different compilers. This can be selected with the
  1369. &quot;build.compiler&quot; property. There are three choices:</p>
  1370. <ul>
  1371. <li>classic (the standard compiler of JDK 1.1/1.2)</li>
  1372. <li>modern (the new compiler of JDK 1.3)</li>
  1373. <li>jikes (the <a
  1374. href="http://oss.software.ibm.com/developerworks/opensource/jikes/project">Jikes</a>
  1375. compiler)</li>
  1376. </ul>
  1377. <p>For JDK 1.1/1.2 is classic the default. For JDK 1.3 is modern the default.</p>
  1378. <h3>Parameters</h3>
  1379. <table border="1" cellpadding="2" cellspacing="0">
  1380. <tr>
  1381. <td valign="top"><b>Attribute</b></td>
  1382. <td valign="top"><b>Description</b></td>
  1383. <td align="center" valign="top"><b>Required</b></td>
  1384. </tr>
  1385. <tr>
  1386. <td valign="top">srcdir</td>
  1387. <td valign="top">location of the java files.</td>
  1388. <td align="center" valign="top">Yes</td>
  1389. </tr>
  1390. <tr>
  1391. <td valign="top">destdir</td>
  1392. <td valign="top">location where to store the class files.</td>
  1393. <td align="center" valign="top">Yes</td>
  1394. </tr>
  1395. <tr>
  1396. <td valign="top">includes</td>
  1397. <td valign="top">comma separated list of patterns of files that must be
  1398. included. All files are included when omitted.</td>
  1399. <td valign="top" align="center">No</td>
  1400. </tr>
  1401. <tr>
  1402. <td valign="top">excludes</td>
  1403. <td valign="top">comma separated list of patterns of files that must be
  1404. excluded. No files (except default excludes) are excluded when omitted.</td>
  1405. <td valign="top" align="center">No</td>
  1406. </tr>
  1407. <tr>
  1408. <td valign="top">defaultexcludes</td>
  1409. <td valign="top">indicates whether default excludes should be used or not
  1410. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  1411. <td valign="top" align="center">No</td>
  1412. </tr>
  1413. <tr>
  1414. <td valign="top">classpath</td>
  1415. <td valign="top">the classpath to use.</td>
  1416. <td align="center" valign="top">No</td>
  1417. </tr>
  1418. <tr>
  1419. <td valign="top">bootclasspath</td>
  1420. <td valign="top">location of bootstrap class files.</td>
  1421. <td align="center" valign="top">No</td>
  1422. </tr>
  1423. <tr>
  1424. <td valign="top">extdirs</td>
  1425. <td valign="top">location of installed extensions.</td>
  1426. <td align="center" valign="top">No</td>
  1427. </tr>
  1428. <tr>
  1429. <td valign="top">debug</td>
  1430. <td valign="top">indicates whether there should be compiled with debug
  1431. information (&quot;on&quot;).</td>
  1432. <td align="center" valign="top">No</td>
  1433. </tr>
  1434. <tr>
  1435. <td valign="top">optimize</td>
  1436. <td valign="top">indicates whether there should be compiled with
  1437. optimization (&quot;on&quot;).</td>
  1438. <td align="center" valign="top">No</td>
  1439. </tr>
  1440. <tr>
  1441. <td valign="top">deprecation</td>
  1442. <td valign="top">indicates whether there should be compiled with deprecation
  1443. information (&quot;on&quot;).</td>
  1444. <td align="center" valign="top">No</td>
  1445. </tr>
  1446. <tr>
  1447. <td valign="top">filtering</td>
  1448. <td valign="top">indicates whether token filtering should take place</td>
  1449. <td valign="top" align="center">No</td>
  1450. </tr>
  1451. </table>
  1452. <h3>Examples</h3>
  1453. <pre> &lt;javac srcdir=&quot;${src}&quot;
  1454. destdir=&quot;${build}&quot;
  1455. classpath=&quot;xyz.jar&quot;
  1456. debug=&quot;on&quot;
  1457. /&gt;</pre>
  1458. <p>compiles all .java files under the directory <code>${src}</code>, and stores
  1459. the .class files in the directory <code>${build}</code>. It also copies the non-java
  1460. files from the tree under <code>${src}</code> to the tree under <code>${build}</code>.
  1461. The classpath used contains <code>xyz.jar</code>, and debug information is on.</p>
  1462. <pre> &lt;javac srcdir=&quot;${src}&quot;
  1463. destdir=&quot;${build}&quot;
  1464. includes=&quot;mypackage/p1/**,mypackage/p2/**&quot;
  1465. excludes=&quot;mypackage/p1/testpackage/**&quot;
  1466. classpath=&quot;xyz.jar&quot;
  1467. debug=&quot;on&quot;
  1468. /&gt;</pre>
  1469. <p>compiles .java files under the directory <code>${src}</code>, and stores the
  1470. .class files in the directory <code>${build}</code>. It also copies the non-java
  1471. files from the tree under <code>${src}</code> to the tree under <code>${build}</code>.
  1472. The classpath used contains <code>xyz.jar</code>, and debug information is on.
  1473. Only files under <code>mypackage/p1</code> and <code>mypackage/p2</code> are
  1474. used. Files in the <code>mypackage/p1/testpackage</code> directory are excluded
  1475. form compilation and copy.</p>
  1476. <hr>
  1477. <h2><a name="javadoc">Javadoc/Javadoc2</a></h2>
  1478. <h3>Description</h3>
  1479. <p>Generates code documentation using the javadoc tool.</p>
  1480. <p>The source directory will be recursively scanned for Java source files to but
  1481. only those matching the inclusion rules will be passed to the javadoc tool. This
  1482. allows wildcards to be used to choose between package names, reducing verbosity
  1483. and management costs over time. This task, however, has no notion of
  1484. &quot;changed&quot; files, unlike the <a href="#javac">javac</a> task, but it's
  1485. not used so frequently.</p>
  1486. <p>This task works seamlessly between different javadoc versions (1.1 and 1.2),
  1487. with the obvious restriction that the 1.2 attributes will be ignored if run in a
  1488. 1.1 VM.</p>
  1489. <p>NOTE: since javadoc calls System.exit(), we cannot run javadoc inside the
  1490. same VM without breaking functionality. For this reason, this task always forks
  1491. the VM. But this is not a performance penalty since javadoc is normally a heavy
  1492. application and must be called just once.</p>
  1493. <p>DEPRECATION: the javadoc2 task simply points to the javadoc task and it's
  1494. there for back compatibility reasons. Since this task will be removed in future
  1495. versions, you are strongly encouraged to use <a href="#javadoc">javadoc</a>
  1496. instead.</p>
  1497. <h3>Parameters</h3>
  1498. <table border="1" cellpadding="2" cellspacing="0">
  1499. <tr>
  1500. <td valign="top"><b>Attribute</b></td>
  1501. <td valign="top"><b>Description</b></td>
  1502. <td align="center" valign="top"><b>Availability</b></td>
  1503. <td align="center" valign="top"><b>Required</b></td>
  1504. </tr>
  1505. <tr>
  1506. <td valign="top">sourcepath</td>
  1507. <td valign="top">Specify where to find source files</td>
  1508. <td align="center" valign="top">all</td>
  1509. <td align="center" valign="top">Yes</td>
  1510. </tr>
  1511. <tr>
  1512. <td valign="top">destdir</td>
  1513. <td valign="top">Destination directory for output files</td>
  1514. <td align="center" valign="top">all</td>
  1515. <td align="center" valign="top">Yes</td>
  1516. </tr>
  1517. <tr>
  1518. <td valign="top">sourcefiles</td>
  1519. <td valign="top">Space separated list of source files</td>
  1520. <td align="center" valign="top">all</td>
  1521. <td align="center" valign="middle" rowspan="2">at least one of the two</td>
  1522. </tr>
  1523. <tr>
  1524. <td valign="top">packagenames</td>
  1525. <td valign="top">Space separated list of package files (with terminating
  1526. wildcard)</td>
  1527. <td align="center" valign="top">all</td>
  1528. </tr>
  1529. <tr>
  1530. <td valign="top">Classpath</td>
  1531. <td valign="top">Specify where to find user class files</td>
  1532. <td align="center" valign="top">all</td>
  1533. <td align="center" valign="top">No</td>
  1534. </tr>
  1535. <tr>
  1536. <td valign="top">Bootclasspath</td>
  1537. <td valign="top">Override location of class files loaded by the bootstrap
  1538. class loader</td>
  1539. <td align="center" valign="top">1.2</td>
  1540. <td align="center" valign="top">No</td>
  1541. </tr>
  1542. <tr>
  1543. <td valign="top">Extdirs</td>
  1544. <td valign="top">Override location of installed extensions</td>
  1545. <td align="center" valign="top">1.2</td>
  1546. <td align="center" valign="top">No</td>
  1547. </tr>
  1548. <tr>
  1549. <td valign="top">Overview</td>
  1550. <td valign="top">Read overview documentation from HTML file</td>
  1551. <td align="center" valign="top">1.2</td>
  1552. <td align="center" valign="top">No</td>
  1553. </tr>
  1554. <tr>
  1555. <td valign="top">Public</td>
  1556. <td valign="top">Show only public classes and members</td>
  1557. <td align="center" valign="top">all</td>
  1558. <td align="center" valign="top">No</td>
  1559. </tr>
  1560. <tr>
  1561. <td valign="top">Protected</td>
  1562. <td valign="top">Show protected/public classes and members (default)</td>
  1563. <td align="center" valign="top">all</td>
  1564. <td align="center" valign="top">No</td>
  1565. </tr>
  1566. <tr>
  1567. <td valign="top">Package</td>
  1568. <td valign="top">Show package/protected/public classes and members</td>
  1569. <td align="center" valign="top">all</td>
  1570. <td align="center" valign="top">No</td>
  1571. </tr>
  1572. <tr>
  1573. <td valign="top">Private</td>
  1574. <td valign="top">Show all classes and members</td>
  1575. <td align="center" valign="top">all</td>
  1576. <td align="center" valign="top">No</td>
  1577. </tr>
  1578. <tr>
  1579. <td valign="top">Old</td>
  1580. <td valign="top">Generate output using JDK 1.1 emulating doclet</td>
  1581. <td align="center" valign="top">1.2</td>
  1582. <td align="center" valign="top">No</td>
  1583. </tr>
  1584. <tr>
  1585. <td valign="top">Verbose</td>
  1586. <td valign="top">Output messages about what Javadoc is doing</td>
  1587. <td align="center" valign="top">1.2</td>
  1588. <td align="center" valign="top">No</td>
  1589. </tr>
  1590. <tr>
  1591. <td valign="top">Locale</td>
  1592. <td valign="top">Locale to be used, e.g. en_US or en_US_WIN</td>
  1593. <td align="center" valign="top">1.2</td>
  1594. <td align="center" valign="top">No</td>
  1595. </tr>
  1596. <tr>
  1597. <td valign="top">Encoding</td>
  1598. <td valign="top">Source file encoding name</td>
  1599. <td align="center" valign="top">all</td>
  1600. <td align="center" valign="top">No</td>
  1601. </tr>
  1602. <tr>
  1603. <td valign="top">Version</td>
  1604. <td valign="top">Include @version paragraphs</td>
  1605. <td align="center" valign="top">all</td>
  1606. <td align="center" valign="top">No</td>
  1607. </tr>
  1608. <tr>
  1609. <td valign="top">Use</td>
  1610. <td valign="top">Create class and package usage pages</td>
  1611. <td align="center" valign="top">1.2</td>
  1612. <td align="center" valign="top">No</td>
  1613. </tr>
  1614. <tr>
  1615. <td valign="top">Author</td>
  1616. <td valign="top">Include @author paragraphs</td>
  1617. <td align="center" valign="top">all</td>
  1618. <td align="center" valign="top">No</td>
  1619. </tr>
  1620. <tr>
  1621. <td valign="top">Splitindex</td>
  1622. <td valign="top">Split index into one file per letter</td>
  1623. <td align="center" valign="top">1.2</td>
  1624. <td align="center" valign="top">No</td>
  1625. </tr>
  1626. <tr>
  1627. <td valign="top">Windowtitle</td>
  1628. <td valign="top">Browser window title for the documenation (text)</td>
  1629. <td align="center" valign="top">1.2</td>
  1630. <td align="center" valign="top">No</td>
  1631. </tr>
  1632. <tr>
  1633. <td valign="top">Doctitle</td>
  1634. <td valign="top">Include title for the package index(first) page (html-code)</td>
  1635. <td align="center" valign="top">1.2</td>
  1636. <td align="center" valign="top">No</td>
  1637. </tr>
  1638. <tr>
  1639. <td valign="top">Header</td>
  1640. <td valign="top">Include header text for each page (html-code)</td>
  1641. <td align="center" valign="top">1.2</td>
  1642. <td align="center" valign="top">No</td>
  1643. </tr>
  1644. <tr>
  1645. <td valign="top">Footer</td>
  1646. <td valign="top">Include footer text for each page (html-code)</td>
  1647. <td align="center" valign="top">1.2</td>
  1648. <td align="center" valign="top">No</td>
  1649. </tr>
  1650. <tr>
  1651. <td valign="top">bottom</td>
  1652. <td valign="top">Include bottom text for each page (html-code)</td>
  1653. <td align="center" valign="top">1.2</td>
  1654. <td align="center" valign="top">No</td>
  1655. </tr>
  1656. <tr>
  1657. <td valign="top">link</td>
  1658. <td valign="top">Create links to javadoc output at the given URL</td>
  1659. <td align="center" valign="top">1.2</td>
  1660. <td align="center" valign="top">No</td>
  1661. </tr>
  1662. <tr>
  1663. <td valign="top">linkoffline</td>
  1664. <td valign="top">Link to docs at &lt;url&gt; using package list at
  1665. &lt;url2&gt;</td>
  1666. <td align="center" valign="top">1.2</td>
  1667. <td align="center" valign="top">No</td>
  1668. </tr>
  1669. <tr>
  1670. <td valign="top">group</td>
  1671. <td valign="top">Group specified packages together in overview page</td>
  1672. <td align="center" valign="top">1.2</td>
  1673. <td align="center" valign="top">No</td>
  1674. </tr>
  1675. <tr>
  1676. <td valign="top">nodeprecated</td>
  1677. <td valign="top">Do not include @deprecated information</td>
  1678. <td align="center" valign="top">all</td>
  1679. <td align="center" valign="top">No</td>
  1680. </tr>
  1681. <tr>
  1682. <td valign="top">nodeprecatedlist</td>
  1683. <td valign="top">Do not generate deprecated list</td>
  1684. <td align="center" valign="top">1.2</td>
  1685. <td align="center" valign="top">No</td>
  1686. </tr>
  1687. <tr>
  1688. <td valign="top">notree</td>
  1689. <td valign="top">Do not generate class hierarchy</td>
  1690. <td align="center" valign="top">all</td>
  1691. <td align="center" valign="top">No</td>
  1692. </tr>
  1693. <tr>
  1694. <td valign="top">noindex</td>
  1695. <td valign="top">Do not generate index</td>
  1696. <td align="center" valign="top">all</td>
  1697. <td align="center" valign="top">No</td>
  1698. </tr>
  1699. <tr>
  1700. <td valign="top">nohelp</td>
  1701. <td valign="top">Do not generate help link</td>
  1702. <td align="center" valign="top">1.2</td>
  1703. <td align="center" valign="top">No</td>
  1704. </tr>
  1705. <tr>
  1706. <td valign="top">nonavbar</td>
  1707. <td valign="top">Do not generate navigation bar</td>
  1708. <td align="center" valign="top">1.2</td>
  1709. <td align="center" valign="top">No</td>
  1710. </tr>
  1711. <tr>
  1712. <td valign="top">serialwarn</td>
  1713. <td valign="top">Generate warning about @serial tag</td>
  1714. <td align="center" valign="top">1.2</td>
  1715. <td align="center" valign="top">No</td>
  1716. </tr>
  1717. <tr>
  1718. <td valign="top">helpfile</td>
  1719. <td valign="top">Specifies the HTML help file to use</td>
  1720. <td align="center" valign="top">1.2</td>
  1721. <td align="center" valign="top">No</td>
  1722. </tr>
  1723. <tr>
  1724. <td valign="top">stylesheetfile</td>
  1725. <td valign="top">Specifies the CSS stylesheet to use</td>
  1726. <td align="center" valign="top">1.2</td>
  1727. <td align="center" valign="top">No</td>
  1728. </tr>
  1729. <tr>
  1730. <td valign="top">charset</td>
  1731. <td valign="top">Charset for cross-platform viewing of generated
  1732. documentation</td>
  1733. <td align="center" valign="top">1.2</td>
  1734. <td align="center" valign="top">No</td>
  1735. </tr>
  1736. <tr>
  1737. <td valign="top">docencoding</td>
  1738. <td valign="top">Output file encoding name</td>
  1739. <td align="center" valign="top">1.1</td>
  1740. <td align="center" valign="top">No</td>
  1741. </tr>
  1742. </table>
  1743. <h3>Example</h3>
  1744. <pre> &lt;javadoc packagenames=&quot;com.dummy.test.*&quot;
  1745. sourcepath=&quot;src&quot;
  1746. destdir=&quot;docs/api&quot;
  1747. author=&quot;true&quot;
  1748. version=&quot;true&quot;
  1749. use=&quot;true&quot;
  1750. windowtitle=&quot;Test API&quot;
  1751. doctitle=&quot;&lt;h1&gt;Test&lt;/h1&gt;&quot;
  1752. bottom=&quot;&lt;i&gt;Copyright &amp;#169; 2000 Dummy Corp. All Rights Reserved.&lt;/i&gt;&quot;
  1753. /&gt;</pre>
  1754. <hr>
  1755. <h2><a name="keysubst">KeySubst</a></h2>
  1756. <h3>Description</h3>
  1757. <p>Performs keyword substitution in the source file, and writes the result to
  1758. the destination file.</p>
  1759. <p>Keys in the source file are of the form ${keyname}. The <i>keys</i> attribute
  1760. contains key/value pairs. When a key is found in the <i>keys</i> attribute, then
  1761. &quot;${keyname}&quot; is replaced by the corresponding value.</p>
  1762. <p>The <i>keys</i> attribute is of the form
  1763. &quot;name1=value1*name2=value2*name3=value3&quot;. The '*' is called the
  1764. separator, which might we changed with the <i>sep</i> attribute.</p>
  1765. <p>Note: the source file and destination file may not be the same.</p>
  1766. <h3>Parameters</h3>
  1767. <table border="1" cellpadding="2" cellspacing="0">
  1768. <tr>
  1769. <td valign="top"><b>Attribute</b></td>
  1770. <td valign="top"><b>Description</b></td>
  1771. <td align="center" valign="top"><b>Required</b></td>
  1772. </tr>
  1773. <tr>
  1774. <td valign="top">src</td>
  1775. <td valign="top">the source file.</td>
  1776. <td align="center" valign="top">Yes</td>
  1777. </tr>
  1778. <tr>
  1779. <td valign="top">dest</td>
  1780. <td valign="top">the destination file.</td>
  1781. <td align="center" valign="top">Yes</td>
  1782. </tr>
  1783. <tr>
  1784. <td valign="top">sep</td>
  1785. <td valign="top">the separator for the name/value pairs.</td>
  1786. <td align="center" valign="top">No</td>
  1787. </tr>
  1788. <tr>
  1789. <td valign="top">keys</td>
  1790. <td valign="top">name/value pairs for replacement.</td>
  1791. <td align="center" valign="top">Yes</td>
  1792. </tr>
  1793. </table>
  1794. <h3>Examples</h3>
  1795. <pre> &lt;keysubst src=&quot;abc.txt&quot; dest=&quot;def.txt&quot; keys=&quot;VERSION=1.0.3*DATE=2000-01-10&quot; /&gt;</pre>
  1796. <hr>
  1797. <h2><a name="mkdir">Mkdir</a></h2>
  1798. <h3>Description</h3>
  1799. <p>Creates a directory. Also non-existent parent directories are created, when
  1800. necessary.</p>
  1801. <h3>Parameters</h3>
  1802. <table border="1" cellpadding="2" cellspacing="0">
  1803. <tr>
  1804. <td valign="top"><b>Attribute</b></td>
  1805. <td valign="top"><b>Description</b></td>
  1806. <td align="center" valign="top"><b>Required</b></td>
  1807. </tr>
  1808. <tr>
  1809. <td valign="top">dir</td>
  1810. <td valign="top">the directory to create.</td>
  1811. <td align="center" valign="top">Yes</td>
  1812. </tr>
  1813. </table>
  1814. <h3>Examples</h3>
  1815. <pre>&lt;mkdir dir=&quot;${dist}&quot; /&gt;</pre>
  1816. <p>creates a directory <code>${dist}</code>.</p>
  1817. <pre>&lt;mkdir dir=&quot;${dist}/lib&quot; /&gt;</pre>
  1818. <p>creates a directory <code>${dist}/lib</code>.</p>
  1819. <hr>
  1820. <h2><a name="property">Property</a></h2>
  1821. <h3>Description</h3>
  1822. <p>Sets a property (by name and value), or set of properties (from file or
  1823. resource) in the project.</p>
  1824. <p>When a property was set by the user, or was a property in a parent project
  1825. (that started this project with the <a href="#ant">ant task</a>), then this
  1826. property cannot be set, and will be ignored. This means that properties set
  1827. outside the current project always override the properties of the current
  1828. project.</p>
  1829. <p>There are three ways to set properties:</p>
  1830. <ul>
  1831. <li>By supplying both the <i>name</i> and <i>value</i> attribute.</li>
  1832. <li>By setting the <i>file</i> attribute with the filename of the property
  1833. file to load. This property file has the format as defined by the file used
  1834. in the class java.util.Properties.</li>
  1835. <li>By setting the <i>resource</i> attribute with the resource name of the
  1836. property file to load. This property file has the format as defined by the
  1837. file used in the class java.util.Properties.</li>
  1838. </ul>
  1839. <p>Although combinations of the three ways are possible, only one should be used
  1840. at a time. Problems might occur with the order in which properties are set, for
  1841. instance.</p>
  1842. <p>The value part of the properties being set, might contain references to other
  1843. properties. These references are resolved at the time these properties are set.
  1844. This also holds for properties loaded from a property file.</p>
  1845. <h3>Parameters</h3>
  1846. <table border="1" cellpadding="2" cellspacing="0">
  1847. <tr>
  1848. <td valign="top"><b>Attribute</b></td>
  1849. <td valign="top"><b>Description</b></td>
  1850. <td align="center" valign="top"><b>Required</b></td>
  1851. </tr>
  1852. <tr>
  1853. <td valign="top">name</td>
  1854. <td valign="top">the name of the property to set.</td>
  1855. <td valign="top" align="center">Yes</td>
  1856. </tr>
  1857. <tr>
  1858. <td valign="top">value</td>
  1859. <td valign="top">the value of the property.</td>
  1860. <td valign="middle" align="center" rowspan="3">Yes</td>
  1861. </tr>
  1862. <tr>
  1863. <td valign="top">resource</td>
  1864. <td valign="top">the resource name of the property file.</td>
  1865. </tr>
  1866. <tr>
  1867. <td valign="top">file</td>
  1868. <td valign="top">the filename of the property file .</td>
  1869. </tr>
  1870. </table>
  1871. <h3>Examples</h3>
  1872. <pre> &lt;property name=&quot;foo.dist&quot; value=&quot;dist&quot; /&gt;</pre>
  1873. <p>sets the property <code>foo.dist</code> to the value &quot;dist&quot;.</p>
  1874. <pre> &lt;property file=&quot;foo.properties&quot; /&gt;</pre>
  1875. <p>reads a set of properties from a file called &quot;foo.properties&quot;.</p>
  1876. <pre> &lt;property resource=&quot;foo.properties&quot; /&gt;</pre>
  1877. <p>reads a set of properties from a resource called &quot;foo.properties&quot;.</p>
  1878. <hr>
  1879. <h2><a name="rename">Rename</a></h2>
  1880. <h3>Description</h3>
  1881. <p>Renames a given file.</p>
  1882. <h3>Parameters</h3>
  1883. <table border="1" cellpadding="2" cellspacing="0">
  1884. <tr>
  1885. <td valign="top"><b>Attribute</b></td>
  1886. <td valign="top"><b>Description</b></td>
  1887. <td align="center" valign="top"><b>Required</b></td>
  1888. </tr>
  1889. <tr>
  1890. <td valign="top">src</td>
  1891. <td valign="top">file to rename.</td>
  1892. <td valign="top" align="center">Yes</td>
  1893. </tr>
  1894. <tr>
  1895. <td valign="top">dest</td>
  1896. <td valign="top">new name of the file.</td>
  1897. <td valign="top" align="center">Yes</td>
  1898. </tr>
  1899. <tr>
  1900. <td valign="top">replace</td>
  1901. <td valign="top">Enable replacing of existing file (default: on).</td>
  1902. <td valign="top" align="center">No</td>
  1903. </tr>
  1904. </table>
  1905. <h3>Examples</h3>
  1906. <pre> &lt;rename src=&quot;foo.jar&quot; dest=&quot;${name}-${version}.jar&quot; /&gt;</pre>
  1907. <p>Renames the file <code>foo.jar</code> to <code>${name}-${version}.jar</code> (assuming <code>name</code>
  1908. and <code>version</code> being predefined properties). If a file named <code>${name}-${version}.jar</code>
  1909. already exists, it will be removed prior to renameing <code>foo.jar</code>.</p>
  1910. <hr>
  1911. <h2><a name="replace">Replace</a></h2>
  1912. <h3>Description</h3>
  1913. <p>Replaces the occurrence of a given string with another string in a file.</p>
  1914. <h3>Parameters</h3>
  1915. <table border="1" cellpadding="2" cellspacing="0">
  1916. <tr>
  1917. <td valign="top"><b>Attribute</b></td>
  1918. <td valign="top"><b>Description</b></td>
  1919. <td align="center" valign="top"><b>Required</b></td>
  1920. </tr>
  1921. <tr>
  1922. <td valign="top">file</td>
  1923. <td valign="top">file for which the token should be replaced.</td>
  1924. <td valign="top" align="center">Yes</td>
  1925. </tr>
  1926. <tr>
  1927. <td valign="top">token</td>
  1928. <td valign="top">the token which must be replaced.</td>
  1929. <td valign="top" align="center">Yes</td>
  1930. </tr>
  1931. <tr>
  1932. <td valign="top">value</td>
  1933. <td valign="top">the new value for the token. When omitted, an empty string
  1934. (&quot;&quot;) is used.</td>
  1935. <td valign="top" align="center">No</td>
  1936. </tr>
  1937. </table>
  1938. <h3>Examples</h3>
  1939. <pre> &lt;replace file=&quot;${src}/index.html&quot; token=&quot;@@@&quot; value=&quot;wombat&quot; /&gt;</pre>
  1940. <p>replaces occurrences of the string &quot;@@@&quot; with the string
  1941. &quot;wombat&quot;, in the file <code>${src}/index.html</code>.</p>
  1942. <hr>
  1943. <h2><a name="rmic">Rmic</a></h2>
  1944. <h3>Description</h3>
  1945. <p>Runs the rmic compiler for a certain class.</p>
  1946. <h3>Parameters</h3>
  1947. <table border="1" cellpadding="2" cellspacing="0">
  1948. <tr>
  1949. <td valign="top"><b>Attribute</b></td>
  1950. <td valign="top"><b>Description</b></td>
  1951. <td align="center" valign="top"><b>Required</b></td>
  1952. </tr>
  1953. <tr>
  1954. <td valign="top">base</td>
  1955. <td valign="top">the location to store the compiled files.</td>
  1956. <td valign="top" align="center">Yes</td>
  1957. </tr>
  1958. <tr>
  1959. <td valign="top">classname</td>
  1960. <td valign="top">the class for which to run <code>rmic</code>.</td>
  1961. <td valign="top" align="center">Yes</td>
  1962. </tr>
  1963. <tr>
  1964. <td valign="top">filtering</td>
  1965. <td valign="top">indicates whether token filtering should take place</td>
  1966. <td valign="top" align="center">No</td>
  1967. </tr>
  1968. </table>
  1969. <h3>Examples</h3>
  1970. <pre> &lt;rmic classname=&quot;com.xyz.FooBar&quot; base=&quot;${build}/classes&quot; /&gt;</pre>
  1971. <p>runs the rmic compiler for the class <code>com.xyz.FooBar</code>. The
  1972. compiled files will be stored in the directory <code>${build}/classes</code>.</p>
  1973. <hr>
  1974. <h2><a name="tar">Tar</a></h2>
  1975. <h3>Description</h3>
  1976. <p>Creates a tar archive.</p>
  1977. <p>The <i>basedir</i> attribute is the reference directory from where to tar.</p>
  1978. <p>It is possible to refine the set of files that are being tarred. This can be
  1979. done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  1980. attributes. With the <i>includes</i> attribute you specify the files you want to
  1981. have included by using patterns. The <i>exclude</i> attribute is used to specify
  1982. the files you want to have excluded. This is also done with patterns. And
  1983. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  1984. want to use default exclusions or not. See the section on <a
  1985. href="#directorybasedtasks">directory based tasks</a>, on how the
  1986. inclusion/exclusion of files works, and how to write patterns. The patterns are
  1987. relative to the <i>basedir</i> directory.</p>
  1988. <p>The <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i> attributes
  1989. replace the <i>items</i> and <i>ignore</i> attributes. The following explains
  1990. how the deprecated <i>items</i> and <i>ignore</i> attribute behave.</p>
  1991. <p>When &quot;*&quot; is used for <i>items</i>, all files in the basedir, and
  1992. its subdirectories, will be tarred. Otherwise all the files and directories
  1993. mentioned in the items list will tarred. When a directory is specified, then all
  1994. files within it are also tarred.</p>
  1995. <p>With the <i>ignore</i> attribute, you can specify files or directories to
  1996. ignore. These files will not be tarred. The items in the <i>ignore</i> attribute
  1997. override the items in the <i>items</i> attribute. The names specified in the <i>ignore</i>
  1998. attribute are just names, they do not contain any path information!</p>
  1999. <p>Note that this task does not perform compression. You might want to use the <a href="#gzip">GZip</a>
  2000. task to come up with a .tar.gz package.</p>
  2001. <h3>Parameters</h3>
  2002. <table border="1" cellpadding="2" cellspacing="0">
  2003. <tr>
  2004. <td valign="top"><b>Attribute</b></td>
  2005. <td valign="top"><b>Description</b></td>
  2006. <td valign="top" align="center"><b>Required</b></td>
  2007. </tr>
  2008. <tr>
  2009. <td valign="top">tarfile</td>
  2010. <td valign="top">the tar-file to create.</td>
  2011. <td align="center" valign="top">Yes</td>
  2012. </tr>
  2013. <tr>
  2014. <td valign="top">basedir</td>
  2015. <td valign="top">the directory from which to zip the files.</td>
  2016. <td align="center" valign="top">Yes</td>
  2017. </tr>
  2018. <tr>
  2019. <td valign="top">includes</td>
  2020. <td valign="top">comma separated list of patterns of files that must be
  2021. included. All files are included when omitted.</td>
  2022. <td valign="top" align="center">No</td>
  2023. </tr>
  2024. <tr>
  2025. <td valign="top">excludes</td>
  2026. <td valign="top">comma separated list of patterns of files that must be
  2027. excluded. No files (except default excludes) are excluded when omitted.</td>
  2028. <td valign="top" align="center">No</td>
  2029. </tr>
  2030. <tr>
  2031. <td valign="top">defaultexcludes</td>
  2032. <td valign="top">indicates whether default excludes should be used or not
  2033. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  2034. <td valign="top" align="center">No</td>
  2035. </tr>
  2036. </table>
  2037. <h3>Examples</h3>
  2038. <pre> &lt;tar tarfile=&quot;${dist}/manual.tar&quot; basedir=&quot;htdocs/manual&quot; /&gt;
  2039. &lt;gzip zipfile=&quot;${dist}/manual.tar.gz&quot; src=&quot;${dist}/manual.tar&quot; /&gt;</pre>
  2040. <p>tars all files in the <code>htdocs/manual</code> directory in a file called <code>manual.tar</code>
  2041. in the <code>${dist}</code> directory, then applies the gzip task to compress
  2042. it.</p>
  2043. <pre> &lt;tar tarfile=&quot;${dist}/manual.tar&quot;
  2044. basedir=&quot;htdocs/manual&quot;
  2045. excludes=&quot;mydocs/**, **/todo.html&quot;
  2046. /&gt;</pre>
  2047. <p>tars all files in the <code>htdocs/manual</code> directory in a file called <code>manual.tar</code>
  2048. in the <code>${dist}</code> directory. Files in the directory <code>mydocs</code>,
  2049. or files with the name <code>todo.html</code> are excluded.</p>
  2050. <hr>
  2051. <h2><a name="taskdef">Taskdef</a></h2>
  2052. <h3>Description</h3>
  2053. <p>Adds a task definition to the current project, such that this new task can be
  2054. used in the current project. Two attributes are needed, the name that identifies
  2055. this task uniquely, and the full name of the class (including the packages) that
  2056. implements this task.</p>
  2057. <p>Taskdef should be used to add your own tasks to the system. See also &quot;<a
  2058. href="#writingowntask">Writing your own task</a>&quot;.</p>
  2059. <h3>Parameters</h3>
  2060. <table border="1" cellpadding="2" cellspacing="0">
  2061. <tr>
  2062. <td valign="top"><b>Attribute</b></td>
  2063. <td valign="top"><b>Description</b></td>
  2064. <td align="center" valign="top"><b>Required</b></td>
  2065. </tr>
  2066. <tr>
  2067. <td valign="top">name</td>
  2068. <td valign="top">the name of the task</td>
  2069. <td valign="top" align="center">Yes</td>
  2070. </tr>
  2071. <tr>
  2072. <td valign="top">classname</td>
  2073. <td valign="top">the full class name implementing the task</td>
  2074. <td valign="top" align="center">Yes</td>
  2075. </tr>
  2076. </table>
  2077. <h3>Examples</h3>
  2078. <pre> &lt;taskdef name=&quot;myjavadoc&quot; classname=&quot;com.mydomain.JavadocTask&quot; /&gt;</pre>
  2079. <p>makes a task called <code>myjavadoc</code> available to Ant. The class <code>com.mydomain.JavadocTask</code>
  2080. implements the task.</p>
  2081. <hr>
  2082. <h2><a name="tstamp">Tstamp</a></h2>
  2083. <h3>Description</h3>
  2084. <p>Sets the DSTAMP, TSTAMP and TODAY properties in the current project. The
  2085. DSTAMP is in the &quot;yyyymmdd&quot; format, the TSTAMP is in the &quot;hhmm&quot;
  2086. format and TODAY is &quot;month day year&quot;.</p>
  2087. <p>These properties can be used in the buildfile, for instance, to create
  2088. timestamped filenames or used to replace placeholder tags inside documents to
  2089. indicate, for example, the release date. The best place for this task is in your
  2090. initialization target.</p>
  2091. <h3>Parameters</h3>
  2092. <table border="1" cellpadding="2" cellspacing="0">
  2093. <tr>
  2094. <td valign="top"><b>Attribute</b></td>
  2095. <td valign="top"><b>Description</b></td>
  2096. <td align="center" valign="top"><b>Required</b></td>
  2097. </tr>
  2098. </table>
  2099. <h3>Examples</h3>
  2100. <pre> &lt;tstamp/&gt;</pre>
  2101. <hr>
  2102. <h2><a name="untar">Untar</a></h2>
  2103. <h3>Description</h3>
  2104. <p>Untars a tarfile.</p>
  2105. <h3>Parameters</h3>
  2106. <table border="1" cellpadding="2" cellspacing="0">
  2107. <tr>
  2108. <td valign="top"><b>Attribute</b></td>
  2109. <td valign="top"><b>Description</b></td>
  2110. <td align="center" valign="top"><b>Required</b></td>
  2111. </tr>
  2112. <tr>
  2113. <td valign="top">src</td>
  2114. <td valign="top">tarfile to expand.</td>
  2115. <td align="center" valign="top">Yes</td>
  2116. </tr>
  2117. <tr>
  2118. <td valign="top">dest</td>
  2119. <td valign="top">directory where to store the expanded files.</td>
  2120. <td align="center" valign="top">Yes</td>
  2121. </tr>
  2122. </table>
  2123. <h3>Examples</h3>
  2124. <blockquote>
  2125. <p><code>
  2126. &lt;gunzip src=&quot;tools.tar.gz&quot;/&gt;<br>
  2127. &lt;untar src=&quot;tools.tar&quot; dest=&quot;${tools.home}&quot;/&gt;
  2128. </code></p>
  2129. </blockquote>
  2130. <hr>
  2131. <h2><a name="zip">Zip</a></h2>
  2132. <h3>Description</h3>
  2133. <p>Creates a zipfile.</p>
  2134. <p>The <i>basedir</i> attribute is the reference directory from where to zip.</p>
  2135. <p>It is possible to refine the set of files that are being zipped. This can be
  2136. done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  2137. attributes. With the <i>includes</i> attribute you specify the files you want to
  2138. have included by using patterns. The <i>exclude</i> attribute is used to specify
  2139. the files you want to have excluded. This is also done with patterns. And
  2140. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  2141. want to use default exclusions or not. See the section on <a
  2142. href="#directorybasedtasks">directory based tasks</a>, on how the
  2143. inclusion/exclusion of files works, and how to write patterns. The patterns are
  2144. relative to the <i>basedir</i> directory.</p>
  2145. <p>The <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i> attributes
  2146. replace the <i>items</i> and <i>ignore</i> attributes. The following explains
  2147. how the deprecated <i>items</i> and <i>ignore</i> attribute behave.</p>
  2148. <p>When &quot;*&quot; is used for <i>items</i>, all files in the basedir, and
  2149. its subdirectories, will be zipped. Otherwise all the files and directories
  2150. mentioned in the items list will zipped. When a directory is specified, then all
  2151. files within it are also zipped.</p>
  2152. <p>With the <i>ignore</i> attribute, you can specify files or directories to
  2153. ignore. These files will not be zipped. The items in the <i>ignore</i> attribute
  2154. override the items in the <i>items</i> attribute. The names specified in the <i>ignore</i>
  2155. attribute are just names, they do not contain any path information!</p>
  2156. <h3>Parameters</h3>
  2157. <table border="1" cellpadding="2" cellspacing="0">
  2158. <tr>
  2159. <td valign="top"><b>Attribute</b></td>
  2160. <td valign="top"><b>Description</b></td>
  2161. <td valign="top" align="center"><b>Required</b></td>
  2162. </tr>
  2163. <tr>
  2164. <td valign="top">zipfile</td>
  2165. <td valign="top">the zip-file to create.</td>
  2166. <td align="center" valign="top">Yes</td>
  2167. </tr>
  2168. <tr>
  2169. <td valign="top">basedir</td>
  2170. <td valign="top">the directory from which to zip the files.</td>
  2171. <td align="center" valign="top">Yes</td>
  2172. </tr>
  2173. <tr>
  2174. <td valign="top">compress</td>
  2175. <td valign="top">Not only store data but also compress them, defaults to true</td>
  2176. <td align="center" valign="top">No</td>
  2177. </tr>
  2178. <tr>
  2179. <td valign="top">items</td>
  2180. <td valign="top">a comma separated list of the files/directories to zip. All
  2181. files are included when omitted. (<b>deprecated</b>, use <i>includes</i>
  2182. instead).</td>
  2183. <td valign="top" align="center">No</td>
  2184. </tr>
  2185. <tr>
  2186. <td valign="top">ignore</td>
  2187. <td valign="top">comma separated list of filenames/directorynames to exclude
  2188. from the zip. No files (except default excludes) are excluded when
  2189. omitted. (<b>deprecated</b>, use <i>excludes</i> instead).</td>
  2190. <td valign="top" align="center">No</td>
  2191. </tr>
  2192. <tr>
  2193. <td valign="top">includes</td>
  2194. <td valign="top">comma separated list of patterns of files that must be
  2195. included. All files are included when omitted.</td>
  2196. <td valign="top" align="center">No</td>
  2197. </tr>
  2198. <tr>
  2199. <td valign="top">excludes</td>
  2200. <td valign="top">comma separated list of patterns of files that must be
  2201. excluded. No files (except default excludes) are excluded when omitted.</td>
  2202. <td valign="top" align="center">No</td>
  2203. </tr>
  2204. <tr>
  2205. <td valign="top">defaultexcludes</td>
  2206. <td valign="top">indicates whether default excludes should be used or not
  2207. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  2208. <td valign="top" align="center">No</td>
  2209. </tr>
  2210. </table>
  2211. <h3>Examples</h3>
  2212. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;
  2213. basedir=&quot;htdocs/manual&quot;
  2214. /&gt;</pre>
  2215. <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
  2216. in the <code>${dist}</code> directory.</p>
  2217. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;
  2218. basedir=&quot;htdocs/manual&quot;
  2219. excludes=&quot;mydocs/**, **/todo.html&quot;
  2220. /&gt;</pre>
  2221. <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
  2222. in the <code>${dist}</code> directory. Files in the directory <code>mydocs</code>,
  2223. or files with the name <code>todo.html</code> are excluded.</p>
  2224. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;
  2225. basedir=&quot;htdocs/manual&quot;
  2226. includes=&quot;api/**/*.html&quot;
  2227. excludes=&quot;**/todo.html&quot;
  2228. /&gt;</pre>
  2229. <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
  2230. in the <code>${dist}</code> directory. Only html files under the directory <code>api</code>
  2231. are zipped, and files with the name <code>todo.html</code> are excluded.</p>
  2232. <h3>Deprecated examples</h3>
  2233. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;
  2234. basedir=&quot;htdocs/manual&quot;
  2235. items=&quot;*&quot;
  2236. /&gt;</pre>
  2237. <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
  2238. in the <code>${dist}</code> directory.</p>
  2239. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;
  2240. basedir=&quot;htdocs/manual&quot;
  2241. items=&quot;*&quot;
  2242. ignore=&quot;mydocs, todo.html&quot;
  2243. /&gt;</pre>
  2244. <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
  2245. in the <code>${dist}</code> directory. Files/directories with the names <code>mydocs</code>
  2246. and <code>todo.html</code> are excluded.</p>
  2247. <hr>
  2248. <h2><a name="writingowntask">Writing your own task</a></h2>
  2249. <p>It is very easy to write your own task:</p>
  2250. <ol>
  2251. <li>Create a Java class that extends <code>org.apache.tools.ant.Task</code>.</li>
  2252. <li>For each attribute, write a setter method. The setter method must be a <code>public
  2253. void</code> method that takes one <code>String</code> as an argument. The
  2254. name of the method must begin with &quot;set&quot;, followed by the
  2255. attribute name, with the first character in uppercase, and the rest in
  2256. lowercase.</li>
  2257. <li>Write a <code>public void execute</code> method, with no arguments, that
  2258. throws a <code>BuildException</code>. This method implements the task
  2259. itself.</li>
  2260. </ol>
  2261. <p>It is important to know that Ant first calls the setters for the attributes
  2262. it encounters for a specific task in the buildfile, before it executes is.</p>
  2263. <p>Let's write our own task, that prints a message on the System.out stream. The
  2264. task has one attribute called &quot;message&quot;.</p>
  2265. <blockquote>
  2266. <pre>package com.mydomain;
  2267. import org.apache.tools.ant.BuildException;
  2268. import org.apache.tools.ant.Task;
  2269. public class MyVeryOwnTask extends Task {
  2270. private String msg;
  2271. // The method executing the task
  2272. public void execute() throws BuildException {
  2273. System.out.println(msg);
  2274. }
  2275. // The setter for the &quot;message&quot; attribute
  2276. public void setMessage(String msg) {
  2277. this.msg = msg;
  2278. }
  2279. }</pre>
  2280. </blockquote>
  2281. <p>It's really this simple;-)</p>
  2282. <p>Adding your task to the system is rather simple too:</p>
  2283. <ol>
  2284. <li>Make sure the class that implements your task is in the classpath when
  2285. starting Ant.</li>
  2286. <li>In your initialization target, add a <i>taskdef</i> task. This actually adds
  2287. your task to the system.</li>
  2288. <li>Use your task in the rest of the buildfile.</li>
  2289. </ol>
  2290. <h3>Example</h3>
  2291. <blockquote>
  2292. <pre>&lt;?xml version=&quot;1.0&quot;?&gt;
  2293. &lt;project name=&quot;OwnTaskExample&quot; default=&quot;main&quot; basedir=&quot;.&quot;&gt;
  2294. &lt;target name=&quot;init&quot;&gt;
  2295. &lt;taskdef name=&quot;mytask&quot; classname=&quot;com.mydomain.MyVeryOwnTask&quot;/&gt;
  2296. &lt;/target&gt;
  2297. &lt;target name=&quot;main&quot; depends=&quot;init&quot;&gt;
  2298. &lt;mytask message=&quot;Hello World! MyVeryOwnTask works!&quot; /&gt;
  2299. &lt;/target&gt;
  2300. &lt;/project&gt;
  2301. </pre>
  2302. </blockquote>
  2303. <p>Another way to add a task (more permanently), is to add the task name and
  2304. implementing class name to the <code>default.properties</code> file in the <code>org.apache.tools.ant.taskdefs</code>
  2305. package. Then you can use it as if it were a built in task.</p>
  2306. <hr>
  2307. <h2><a name="feedback">Feedback</a></h2>
  2308. <p>To provide feedback on this software, please subscribe to the Ant Development
  2309. Mail List <a href="mailto:(ant-dev-subscribe@jakarta.apache.org">(ant-dev-subscribe@jakarta.apache.org</a>)</p>
  2310. <hr>
  2311. <p align="center">Copyright 2000 Apache Software Foundation. All rights
  2312. Reserved.</p>
  2313. <h2><a name="optionaltasks">Optional tasks</a></h2>
  2314. <ul>
  2315. <li><a href="#netrexxc">NetRexxC</a></li>
  2316. <li><a href="#renameexts">RenameExtensions</a></li>
  2317. <li><a href="#script">Script</a></li>
  2318. </ul>
  2319. <hr>
  2320. <h2><a name="netrexxc">NetRexxC</a></h2>
  2321. <h3><b>Description:</b></h3>
  2322. <p>Compiles a <a href="http://www2.hursley.ibm.com/netrexx">NetRexx</a>
  2323. source tree within the running (Ant) VM.</p>
  2324. <p>The source and destination directory will be recursively scanned for
  2325. NetRexx source files to compile. Only NetRexx files that have no corresponding
  2326. class file or where the class file is older than the java file will be compiled.</p>
  2327. <p>Files in the source tree are copied to the destination directory,
  2328. allowing support files to be located properly in the classpath. The source
  2329. files are copied because the NetRexx compiler cannot produce class files in a
  2330. specific directory via parameters</p>
  2331. <p>The directory structure of the source tree should follow the package
  2332. hierarchy.</p>
  2333. <p>It is possible to refine the set of files that are being compiled/copied.
  2334. This can be done with the <i>includes</i>, <i>excludes</i> and
  2335. <i>defaultexcludes</i> attributes. With the <i>includes</i> attribute you
  2336. specify the files you want to have included by using patterns. The
  2337. <i>exclude</i> attribute is used to specify the files you want to have
  2338. excluded. This is also done with patterns. And finally with the
  2339. <i>defaultexcludes</i> attribute, you can specify whether you
  2340. want to use default exclusions or not. See the section on <a
  2341. href="#directorybasedtasks">directory based tasks</a>, on how the
  2342. inclusion/exclusion of files works, and how to write patterns. The
  2343. patterns are relative to the <i>srcDir</i> directory.</p>
  2344. <h3>Parameters:</h3>
  2345. <table border="1" cellpadding="2" cellspacing="0">
  2346. <tr>
  2347. <td valign="top"><b>Attribute</b></td>
  2348. <td valign="top"><b>Description</b></td>
  2349. <td align="center" valign="top"><b>Required</b></td>
  2350. </tr>
  2351. <tr>
  2352. <td valign="top">binary</td>
  2353. <td valign="top">Whether literals are treated as the java binary
  2354. type rather than the NetRexx types</td>
  2355. <td valign="top" align="center">No</td>
  2356. </tr>
  2357. <tr>
  2358. <td valign="top">classpath</td>
  2359. <td valign="top">The classpath to use during compilation</td>
  2360. <td valign="top" align="center">No</td>
  2361. </tr>
  2362. <tr>
  2363. <td valign="top">comments</td>
  2364. <td valign="top">Whether comments are passed through to the
  2365. generated java source</td>
  2366. <td valign="top" align="center">No</td>
  2367. </tr>
  2368. <tr>
  2369. <td valign="top">compact</td>
  2370. <td valign="top">Whether error messages come out in compact or
  2371. verbose format</td>
  2372. <td valign="top" align="center">No</td>
  2373. </tr>
  2374. <tr>
  2375. <td valign="top">compile</td>
  2376. <td valign="top">Whether the NetRexx compiler should compile the
  2377. generated java code</td>
  2378. <td valign="top" align="center">No</td>
  2379. </tr>
  2380. <tr>
  2381. <td valign="top">console</td>
  2382. <td valign="top">Whether or not messages should be displayed on the
  2383. 'console'</td>
  2384. <td valign="top" align="center">No</td>
  2385. </tr>
  2386. <tr>
  2387. <td valign="top">crossref</td>
  2388. <td valign="top">Whether variable cross references are generated</td>
  2389. <td valign="top" align="center">No</td>
  2390. </tr>
  2391. <tr>
  2392. <td valign="top">decimal</td>
  2393. <td valign="top">Whether decimal arithmetic should be used for the
  2394. NetRexx code</td>
  2395. <td valign="top" align="center">No</td>
  2396. </tr>
  2397. <tr>
  2398. <td valign="top">defaultexcludes</td>
  2399. <td valign="top">indicates whether default excludes should be used or not
  2400. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
  2401. omitted.</td>
  2402. <td valign="top" align="center">No</td>
  2403. </tr>
  2404. <tr>
  2405. <td valign="top">destDir</td>
  2406. <td valign="top">the destination directory into which the NetRexx
  2407. source files should be copied and then compiled</td>
  2408. <td valign="top" align="center">Yes</td>
  2409. </tr>
  2410. <tr>
  2411. <td valign="top">diag</td>
  2412. <td valign="top">Whether diagnostic information about the compile is
  2413. generated</td>
  2414. <td valign="top" align="center">No</td>
  2415. </tr>
  2416. <tr>
  2417. <td valign="top">excludes</td>
  2418. <td valign="top">comma separated list of patterns of files that must be
  2419. excluded. No files (except default excludes) are excluded when
  2420. omitted.</td>
  2421. <td valign="top" align="center">No</td>
  2422. </tr>
  2423. <tr>
  2424. <td valign="top">explicit</td>
  2425. <td valign="top">Whether variables must be declared explicitly
  2426. before use</td>
  2427. <td valign="top" align="center">No</td>
  2428. </tr>
  2429. <tr>
  2430. <td valign="top">format</td>
  2431. <td valign="top">Whether the generated java code is formatted nicely
  2432. or left to match NetRexx line numbers for call stack debugging</td>
  2433. <td valign="top" align="center">No</td>
  2434. </tr>
  2435. <tr>
  2436. <td valign="top">includes</td>
  2437. <td valign="top">comma separated list of patterns of files that must be
  2438. included. All files are included when omitted.</td>
  2439. <td valign="top" align="center">No</td>
  2440. </tr>
  2441. <tr>
  2442. <td valign="top">java</td>
  2443. <td valign="top">Whether the generated java code is produced</td>
  2444. <td valign="top" align="center">No</td>
  2445. </tr>
  2446. <tr>
  2447. <td valign="top">keep</td>
  2448. <td valign="top">Sets whether the generated java source file should be kept
  2449. after compilation. The generated files will have an extension of
  2450. .java.keep, <b>not</b> .java</td>
  2451. <td valign="top" align="center">No</td>
  2452. </tr>
  2453. <tr>
  2454. <td valign="top">logo</td>
  2455. <td valign="top">Whether the compiler text logo is displayed when
  2456. compiling</td>
  2457. <td valign="top" align="center">No</td>
  2458. </tr>
  2459. <tr>
  2460. <td valign="top">replace</td>
  2461. <td valign="top">Whether the generated .java file should be replaced
  2462. when compiling</td>
  2463. <td valign="top" align="center">No</td>
  2464. </tr>
  2465. <tr>
  2466. <td valign="top">savelog</td>
  2467. <td valign="top">Whether the compiler messages will be written to
  2468. NetRexxC.log as well as to the console</td>
  2469. <td valign="top" align="center">No</td>
  2470. </tr>
  2471. <tr>
  2472. <td valign="top">sourcedir</td>
  2473. <td valign="top">Tells the NetRexx compiler to store the class files in the
  2474. same directory as the source files. The alternative is the working
  2475. directory</td>
  2476. <td valign="top" align="center">No</td>
  2477. </tr>
  2478. <tr>
  2479. <td valign="top">srcDir</td>
  2480. <td valign="top">Set the source dir to find the source Netrexx
  2481. files</td>
  2482. <td valign="top" align="center">Yes</td>
  2483. </tr>
  2484. <tr>
  2485. <td valign="top">strictargs</td>
  2486. <td valign="top">Tells the NetRexx compiler that method calls always
  2487. need parentheses, even if no arguments are needed, e.g.
  2488. <code>aStringVar.getBytes</code> vs.
  2489. <code>aStringVar.getBytes()</code></td>
  2490. <td valign="top" align="center">No</td>
  2491. </tr>
  2492. <tr>
  2493. <td valign="top">strictassign</td>
  2494. <td valign="top">Tells the NetRexx compile that assignments must
  2495. match exactly on type</td>
  2496. <td valign="top" align="center">No</td>
  2497. </tr>
  2498. <tr>
  2499. <td valign="top">strictcase</td>
  2500. <td valign="top">Specifies whether the NetRexx compiler should be
  2501. case sensitive or not</td>
  2502. <td valign="top" align="center">No</td>
  2503. </tr>
  2504. <tr>
  2505. <td valign="top">strictimport</td>
  2506. <td valign="top">Whether classes need to be imported explicitly using an
  2507. <code>import</code> statement. By default the NetRexx compiler will
  2508. import certain packages automatically</td>
  2509. <td valign="top" align="center">No</td>
  2510. </tr>
  2511. <tr>
  2512. <td valign="top">strictprops</td>
  2513. <td valign="top">Whether local properties need to be qualified
  2514. explicitly using <code>this</code></td>
  2515. <td valign="top" align="center">No</td>
  2516. </tr>
  2517. <tr>
  2518. <td valign="top">strictsignal</td>
  2519. <td valign="top">Whether the compiler should force catching of
  2520. exceptions by explicitly named types</td>
  2521. <td valign="top" align="center">No</td>
  2522. </tr>
  2523. <tr>
  2524. <td valign="top">symbols</td>
  2525. <td valign="top">Whether debug symbols should be generated into the
  2526. class file</td>
  2527. <td valign="top" align="center">No</td>
  2528. </tr>
  2529. <tr>
  2530. <td valign="top">time</td>
  2531. <td valign="top">Asks the NetRexx compiler to print compilation
  2532. times to the console</td>
  2533. <td valign="top" align="center">No</td>
  2534. </tr>
  2535. <tr>
  2536. <td valign="top">trace</td>
  2537. <td valign="top">Turns on or off tracing and directs the resultant
  2538. trace output</td>
  2539. <td valign="top" align="center">No</td>
  2540. </tr>
  2541. <tr>
  2542. <td valign="top">utf8</td>
  2543. <td valign="top">Tells the NetRexx compiler that the source is in UTF8</td>
  2544. <td valign="top" align="center">No</td>
  2545. </tr>
  2546. <tr>
  2547. <td valign="top">verbose</td>
  2548. <td valign="top">Whether lots of warnings and error messages should
  2549. be generated</td>
  2550. <td valign="top" align="center">Yes</td>
  2551. </tr>
  2552. </table>
  2553. <h3>Examples</h3>
  2554. <blockquote>
  2555. <p><code>&lt;netrexxc srcDir=&quot;/source/project&quot;
  2556. includes=&quot;vnr/util/*&quot;
  2557. destDir=&quot;/source/project/build&quot;
  2558. classpath=&quot;/source/project2/proj.jar&quot;
  2559. comments=&quot;true&quot;
  2560. crossref=&quot;false&quot; replace=&quot;true&quot;
  2561. keep=&quot;true&quot; /&gt;</code>
  2562. </p>
  2563. </blockquote>
  2564. <hr>
  2565. <h2><a name="renameexts">RenameExtensions</a></h2>
  2566. <h3><b>Description:</b></h3>
  2567. <p>Renames files in the <code>srcDir</code> directory ending with the
  2568. <code>fromExtension</code> string so that they end with the
  2569. <code>toExtension</code> string. Files are only replaced if
  2570. <code>replace</code> is true
  2571. </p>
  2572. <p>See the section on
  2573. <a href="#directorybasedtasks">directory based tasks</a>, on how the
  2574. inclusion/exclusion of files works, and how to write patterns. The
  2575. patterns are relative to the <i>srcDir</i> directory.</p>
  2576. <h3>Parameters:</h3>
  2577. <table border="1" cellpadding="2" cellspacing="0">
  2578. <tr>
  2579. <td valign="top"><b>Attribute</b></td>
  2580. <td valign="top"><b>Description</b></td>
  2581. <td align="center" valign="top"><b>Required</b></td>
  2582. </tr>
  2583. <tr>
  2584. <td valign="top">defaultexcludes</td>
  2585. <td valign="top">indicates whether default excludes should be used or not
  2586. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
  2587. omitted.</td>
  2588. <td valign="top" align="center">No</td>
  2589. </tr>
  2590. <tr>
  2591. <td valign="top">excludes</td>
  2592. <td valign="top">comma separated list of patterns of files that must be
  2593. excluded. No files (except default excludes) are excluded when
  2594. omitted.</td>
  2595. <td valign="top" align="center">No</td>
  2596. </tr>
  2597. <tr>
  2598. <td valign="top">fromExtention</td>
  2599. <td valign="top">The string that files must end in to be renamed</td>
  2600. <td valign="top" align="center">Yes</td>
  2601. </tr>
  2602. <tr>
  2603. <td valign="top">includes</td>
  2604. <td valign="top">comma separated list of patterns of files that must be
  2605. included. All files are included when omitted.</td>
  2606. <td valign="top" align="center">No</td>
  2607. </tr>
  2608. <tr>
  2609. <td valign="top">replace</td>
  2610. <td valign="top">Whether the file being renamed to should be
  2611. replaced if it already exists</td>
  2612. <td valign="top" align="center">No</td>
  2613. </tr>
  2614. <tr>
  2615. <td valign="top">srcDir</td>
  2616. <td valign="top">The starting directory for files to search in</td>
  2617. <td valign="top" align="center">Yes</td>
  2618. </tr>
  2619. <tr>
  2620. <td valign="top">toExtension</td>
  2621. <td valign="top">The string that renamed files will end with on
  2622. completion</td>
  2623. <td valign="top" align="center">Yes</td>
  2624. </tr>
  2625. </table>
  2626. <h3>Examples</h3>
  2627. <blockquote>
  2628. <p><code>&lt;renameext srcDir=&quot;/source/project1&quot;
  2629. includes=&quot;**&quot;
  2630. excludes=&quot;**/samples/*&quot;
  2631. fromExtension=&quot;.java.keep&quot;
  2632. toExtension=&quot;.java&quot;
  2633. replace=&quot;true&quot; /&gt;
  2634. </code>
  2635. </p>
  2636. </blockquote>
  2637. <hr>
  2638. <h2><a name="script">Script</a></h2>
  2639. <h3><b>Description:</b></h3>
  2640. <p>Execute a script in a
  2641. <a href="http://www.alphaworks.ibm.com/tech/bsf">BSF</a> supported language.
  2642. <p>All items (tasks, targets, etc) of the running project are accessible
  2643. from the script.
  2644. <h3>Parameters:</h3>
  2645. <table border="1" cellpadding="2" cellspacing="0">
  2646. <tr>
  2647. <td valign="top"><b>Attribute</b></td>
  2648. <td valign="top"><b>Description</b></td>
  2649. <td align="center" valign="top"><b>Required</b></td>
  2650. </tr>
  2651. <tr>
  2652. <td valign="top">language</td>
  2653. <td valign="top">The programming language the script is written in.
  2654. Must be a supported BSF language</td>
  2655. <td valign="top" align="center">No</td>
  2656. </tr>
  2657. <tr>
  2658. <td valign="top">src</td>
  2659. <td valign="top">The location of the script as a file, if not inline</td>
  2660. <td valign="top" align="center">No</td>
  2661. </tr>
  2662. </table>
  2663. <h3>Examples</h3>
  2664. <blockquote>
  2665. <p>None yet available</p>
  2666. </blockquote>
  2667. </body>
  2668. </html>