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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710
  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. make's 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>Handles packages/modules retrieved from a
  721. <a href="http://www.cyclic.com/">CVS</a> repository.</p>
  722. <p>When doing automated builds, the <a href="#get">get task</a> should be
  723. preferred over the <i>checkout</i> command, 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">command</td>
  733. <td valign="top">the CVS command to execute.</td>
  734. <td align="center" valign="top">No, default &quot;checkout&quot;</td>
  735. </tr>
  736. <tr>
  737. <td valign="top">cvsRoot</td>
  738. <td valign="top">the CVSROOT variable.</td>
  739. <td align="center" valign="top">No</td>
  740. </tr>
  741. <tr>
  742. <td valign="top">dest</td>
  743. <td valign="top">the directory where the checked out files should be placed.</td>
  744. <td align="center" valign="top">Yes</td>
  745. </tr>
  746. <tr>
  747. <td valign="top">package</td>
  748. <td valign="top">the package/module to check out.</td>
  749. <td align="center" valign="top">No</td>
  750. </tr>
  751. <tr>
  752. <td valign="top">tag</td>
  753. <td valign="top">the tag of the package/module to check out.</td>
  754. <td align="center" valign="top">No</td>
  755. </tr>
  756. <tr>
  757. <td valign="top">quiet</td>
  758. <td valign="top">supress informational messages.</td>
  759. <td align="center" valign="top">No, default &quot;false&quot;</td>
  760. </tr>
  761. <tr>
  762. <td valign="top">noexec</td>
  763. <td valign="top">report only, don't change any files.</td>
  764. <td align="center" valign="top">No, default &quot;false&quot;</td>
  765. </tr>
  766. </table>
  767. <h3>Examples</h3>
  768. <pre> &lt;cvs cvsRoot=&quot;:pserver:anoncvs@jakarta.apache.org:/home/cvspublic&quot;
  769. package=&quot;jakarta-tools&quot;
  770. dest=&quot;${ws.dir}&quot;
  771. /&gt;</pre>
  772. <p>checks out the package/module &quot;jakarta-tools&quot; from the CVS
  773. repository pointed to by the cvsRoot attribute, and stores the files in &quot;${ws.dir}&quot;.</p>
  774. <pre> &lt;cvs dest=&quot;${ws.dir}&quot; command=&quot;update&quot; /&gt;</pre>
  775. <p>updates the package/module that has previously been checked out into
  776. &quot;${ws.dir}&quot;.</p>
  777. <hr>
  778. <h2><a name="delete">Delete</a></h2>
  779. <h3>Description</h3>
  780. <p>Deletes either a single file or
  781. all files in a specified directory and its sub-directories.</p>
  782. <p>It is possible to refine the set of files that are being deleted. This can be
  783. done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  784. attributes. With the <i>includes</i> attribute you specify the files you want to
  785. have included in the deletion process by using patterns. The <i>exclude</i> attribute is used to specify
  786. the files you want to have excluded from the deletion process. This is also done with patterns. And
  787. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  788. want to use default exclusions or not. See the section on <a
  789. href="#directorybasedtasks">directory based tasks</a>, on how the
  790. inclusion/exclusion of files works, and how to write patterns. The patterns are
  791. relative to the <i>dir</i> directory.</p>
  792. <h3>Parameters</h3>
  793. <table border="1" cellpadding="2" cellspacing="0">
  794. <tr>
  795. <td valign="top"><b>Attribute</b></td>
  796. <td valign="top"><b>Description</b></td>
  797. <td align="center" valign="top"><b>Required</b></td>
  798. </tr>
  799. <tr>
  800. <td valign="top">file</td>
  801. <td valign="top">The file to delete.</td>
  802. <td align="center" valign="middle" rowspan="2">at least one of the two</td>
  803. </tr>
  804. <tr>
  805. <td valign="top">dir</td>
  806. <td valign="top">The directory to delete files from.</td>
  807. </tr>
  808. <tr>
  809. <td valign="top">includes</td>
  810. <td valign="top">Comma separated list of patterns of files that must be
  811. deleted. All files are in the current directory
  812. and any sub-directories are deleted when omitted.</td>
  813. <td valign="top" align="center">No</td>
  814. </tr>
  815. <tr>
  816. <td valign="top">excludes</td>
  817. <td valign="top">Comma separated list of patterns of files that must be
  818. excluded from the deletion list. No files (except default excludes) are excluded when omitted.</td>
  819. <td valign="top" align="center">No</td>
  820. </tr>
  821. <tr>
  822. <td valign="top">defaultexcludes</td>
  823. <td valign="top">Indicates whether default excludes should be used or not
  824. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  825. <td valign="top" align="center">No</td>
  826. </tr>
  827. <tr>
  828. <td valign="top">verbose</td>
  829. <td valign="top">Show name of each deleted file (&quot;true&quot;/&quot;false&quot;). Default is "false" when omitted.</td>
  830. <td align="center" valign="top">No</td>
  831. </tr>
  832. </table>
  833. <h3>Examples</h3>
  834. <pre> &lt;delete file=&quot;/lib/ant.jar&quot; /&gt;</pre>
  835. <p>deletes the file <code>/lib/ant.jar</code>.</p>
  836. <pre> &lt;delete dir=&quot;lib&quot; /&gt;</pre>
  837. <p>deletes all files in the <code>/lib</code> directory.</p>
  838. <pre> &lt;delete dir=&quot;.&quot;
  839. include=&quot;**/*.bak&quot;
  840. /&gt;
  841. </pre>
  842. <p>deletes all files with the extension &quot;<code>.bak</code>&quot from the current directory
  843. and any sub-directories.</p>
  844. <h2><a name="deltree">Deltree</a></h2>
  845. <h3>Description</h3>
  846. <p>Deletes a directory with all its files and subdirectories.</p>
  847. <h3>Parameters</h3>
  848. <table border="1" cellpadding="2" cellspacing="0">
  849. <tr>
  850. <td valign="top"><b>Attribute</b></td>
  851. <td valign="top"><b>Description</b></td>
  852. <td align="center" valign="top"><b>Required</b></td>
  853. </tr>
  854. <tr>
  855. <td valign="top">dir</td>
  856. <td valign="top">the directory to delete.</td>
  857. <td valign="top" align="center">Yes</td>
  858. </tr>
  859. </table>
  860. <h3>Examples</h3>
  861. <pre> &lt;deltree dir=&quot;dist&quot; /&gt;</pre>
  862. <p>deletes the directory <code>dist</code>, including its files and
  863. subdirectories.</p>
  864. <pre> &lt;deltree dir=&quot;${dist}&quot; /&gt;</pre>
  865. <p>deletes the directory <code>${dist}</code>, including its files and
  866. subdirectories.</p>
  867. <hr>
  868. <h2><a name="echo">Echo</a></h2>
  869. <h3>Description</h3>
  870. <p>Echoes a message to System.out.</p>
  871. <h3>Parameters</h3>
  872. <table border="1" cellpadding="2" cellspacing="0">
  873. <tr>
  874. <td valign="top"><b>Attribute</b></td>
  875. <td valign="top"><b>Description</b></td>
  876. <td align="center" valign="top"><b>Required</b></td>
  877. </tr>
  878. <tr>
  879. <td valign="top">message</td>
  880. <td valign="top">the message to echo.</td>
  881. <td valign="top" align="center">Yes</td>
  882. </tr>
  883. </table>
  884. <h3>Examples</h3>
  885. <pre> &lt;echo message=&quot;Hello world&quot; /&gt;</pre>
  886. <hr>
  887. <h2><a name="exec">Exec</a></h2>
  888. <h3>Description</h3>
  889. <p>Executes a system command. When the <i>os</i> attribute is specified, then
  890. the command is only executed when Ant is run on one of the specified operating
  891. systems.</p>
  892. <h3>Parameters</h3>
  893. <table border="1" cellpadding="2" cellspacing="0">
  894. <tr>
  895. <td valign="top"><b>Attribute</b></td>
  896. <td valign="top"><b>Description</b></td>
  897. <td align="center" valign="top"><b>Required</b></td>
  898. </tr>
  899. <tr>
  900. <td valign="top">command</td>
  901. <td valign="top">the command to execute.</td>
  902. <td align="center" valign="top">Yes</td>
  903. </tr>
  904. <tr>
  905. <td valign="top">dir</td>
  906. <td valign="top">the directory in which the command should be executed.</td>
  907. <td align="center" valign="top">Yes</td>
  908. </tr>
  909. <tr>
  910. <td valign="top">os</td>
  911. <td valign="top">list of Operating Systems on which the command may be
  912. executed.</td>
  913. <td align="center" valign="top">No</td>
  914. </tr>
  915. <tr>
  916. <td valign="top">output</td>
  917. <td valign="top">the file to which the output of the command should be
  918. redirected.</td>
  919. <td align="center" valign="top">Yes</td>
  920. </tr>
  921. </table>
  922. <h3>Examples</h3>
  923. <blockquote>
  924. <p><code>&lt;exec dir=&quot;${src}&quot; command=&quot;dir&quot; os=&quot;windows&quot;
  925. output=&quot;dir.txt&quot; /&gt;</code></p>
  926. </blockquote>
  927. <hr>
  928. <h2><a name="expand">Expand</a></h2>
  929. <h3>Description</h3>
  930. <p>Unzips a zipfile.</p>
  931. <h3>Parameters</h3>
  932. <table border="1" cellpadding="2" cellspacing="0">
  933. <tr>
  934. <td valign="top"><b>Attribute</b></td>
  935. <td valign="top"><b>Description</b></td>
  936. <td align="center" valign="top"><b>Required</b></td>
  937. </tr>
  938. <tr>
  939. <td valign="top">src</td>
  940. <td valign="top">zipfile to expand.</td>
  941. <td align="center" valign="top">Yes</td>
  942. </tr>
  943. <tr>
  944. <td valign="top">dest</td>
  945. <td valign="top">directory where to store the expanded files.</td>
  946. <td align="center" valign="top">Yes</td>
  947. </tr>
  948. </table>
  949. <h3>Examples</h3>
  950. <blockquote>
  951. <p><code>&lt;expand src=&quot;${tomcat_src}/tools-src.zip&quot; dest=&quot;${tools.home}&quot;
  952. /&gt;</code></p>
  953. </blockquote>
  954. <hr>
  955. <h2><a name="filter">Filter</a></h2>
  956. <h3>Description</h3>
  957. <p>Sets a token filter for this project. Token filters are used by all tasks
  958. that perform file copying operations through the Project commodity methods.</p>
  959. <p>Note: the token string must not contain the separators chars (@).</p>
  960. <h3>Parameters</h3>
  961. <table border="1" cellpadding="2" cellspacing="0">
  962. <tr>
  963. <td valign="top"><b>Attribute</b></td>
  964. <td valign="top"><b>Description</b></td>
  965. <td align="center" valign="top"><b>Required</b></td>
  966. </tr>
  967. <tr>
  968. <td valign="top">token</td>
  969. <td valign="top">the token string without @</td>
  970. <td align="center" valign="top">Yes</td>
  971. </tr>
  972. <tr>
  973. <td valign="top">value</td>
  974. <td valign="top">the string that should be put to replace the token when the
  975. file is copied</td>
  976. <td align="center" valign="top">Yes</td>
  977. </tr>
  978. </table>
  979. <h3>Examples</h3>
  980. <pre> &lt;filter token=&quot;year&quot; value=&quot;2000&quot; /&gt;
  981. &lt;copydir src=&quot;${src.dir}&quot; dest=&quot;${dest.dir}&quot;/&gt;</pre>
  982. <p>will copy recursively all the files from the <i>src.dir</i> directory into
  983. the <i>dest.dir</i> directory replacing all the occurencies of the string <i>@year@</i>
  984. with <i>2000.</i></p>
  985. <hr>
  986. <h2><a name="get">Get</a></h2>
  987. <h3>Description</h3>
  988. <p>Gets a file from an URL. When the verbose option is &quot;on&quot;, this task
  989. displays a '.' for every 100 Kb retrieved.</p>
  990. <p>This task should be preferred above the <a href="#cvs">CVS task</a> when
  991. doing automated builds. CVS is significant slower than loading a compressed
  992. archive with http/ftp.</p>
  993. <h3>Parameters</h3>
  994. <table border="1" cellpadding="2" cellspacing="0">
  995. <tr>
  996. <td valign="top"><b>Attribute</b></td>
  997. <td valign="top"><b>Description</b></td>
  998. <td align="center" valign="top"><b>Required</b></td>
  999. </tr>
  1000. <tr>
  1001. <td valign="top">src</td>
  1002. <td valign="top">the URL from which to retrieve a file.</td>
  1003. <td align="center" valign="top">Yes</td>
  1004. </tr>
  1005. <tr>
  1006. <td valign="top">dest</td>
  1007. <td valign="top">the file where to store the retrieved file.</td>
  1008. <td align="center" valign="top">Yes</td>
  1009. </tr>
  1010. <tr>
  1011. <td valign="top">verbose</td>
  1012. <td valign="top">show verbose information (&quot;on&quot;/&quot;off&quot;).</td>
  1013. <td align="center" valign="top">No</td>
  1014. </tr>
  1015. </table>
  1016. <h3>Examples</h3>
  1017. <pre> &lt;get src=&quot;http://jakarta.apache.org/&quot; dest=&quot;help/index.html&quot; /&gt;</pre>
  1018. <p>gets the index page of http://jakarta.apache.org/, and stores it in the file <code>help/index.html</code>.</p>
  1019. <hr>
  1020. <h2><a name="gunzip">GUnzip</a></h2>
  1021. <h3>Description</h3>
  1022. <p>Expands a GZip file.</p>
  1023. <p>If <i>dest</i> is a directory the name of the destination file is
  1024. the same as <i>src</i> (with the &quot;.gz&quot; extension removed if
  1025. present). If <i>dest</i> is ommited, the parent dir of <i>src</i> is
  1026. taken. The file is only expanded if the source file is newer than the
  1027. destination file, or when the destination file does not exist.</p>
  1028. <h3>Parameters</h3>
  1029. <table border="1" cellpadding="2" cellspacing="0">
  1030. <tr>
  1031. <td valign="top"><b>Attribute</b></td>
  1032. <td valign="top"><b>Description</b></td>
  1033. <td align="center" valign="top"><b>Required</b></td>
  1034. </tr>
  1035. <tr>
  1036. <td valign="top">src</td>
  1037. <td valign="top">the file to expand.</td>
  1038. <td align="center" valign="top">Yes</td>
  1039. </tr>
  1040. <tr>
  1041. <td valign="top">dest</td>
  1042. <td valign="top">the destination file or directory.</td>
  1043. <td align="center" valign="top">No</td>
  1044. </tr>
  1045. </table>
  1046. <h3>Examples</h3>
  1047. <blockquote>
  1048. <p><code>&lt;gunzip src=&quot;test.tar.gz&quot;/&gt;</code></p>
  1049. </blockquote>
  1050. <p>expands <i>test.tar.gz</i> to <i>test.tar</i></p>
  1051. <blockquote>
  1052. <p><code>&lt;gunzip src=&quot;test.tar.gz&quot; dest=&quot;test2.tar&quot;/&gt;</code></p>
  1053. </blockquote>
  1054. <p>expands <i>test.tar.gz</i> to <i>test2.tar</i></p>
  1055. <blockquote>
  1056. <p><code>&lt;gunzip src=&quot;test.tar.gz&quot; dest=&quot;subdir&quot;/&gt;</code></p>
  1057. </blockquote>
  1058. <p>expands <i>test.tar.gz</i> to <i>subdir/test.tar</i> (assuming
  1059. subdir is a directory).</p>
  1060. <hr>
  1061. <h2><a name="gzip">GZip</a></h2>
  1062. <h3>Description</h3>
  1063. <p>GZips a file.</p>
  1064. <h3>Parameters</h3>
  1065. <table border="1" cellpadding="2" cellspacing="0">
  1066. <tr>
  1067. <td valign="top"><b>Attribute</b></td>
  1068. <td valign="top"><b>Description</b></td>
  1069. <td align="center" valign="top"><b>Required</b></td>
  1070. </tr>
  1071. <tr>
  1072. <td valign="top">src</td>
  1073. <td valign="top">the file to gzip.</td>
  1074. <td align="center" valign="top">Yes</td>
  1075. </tr>
  1076. <tr>
  1077. <td valign="top">zipfile</td>
  1078. <td valign="top">the destination file.</td>
  1079. <td align="center" valign="top">Yes</td>
  1080. </tr>
  1081. </table>
  1082. <h3>Examples</h3>
  1083. <blockquote>
  1084. <p><code>&lt;gzip src=&quot;test.tar&quot; zipfile=&quot;test.tar.gz&quot;
  1085. /&gt;</code></p>
  1086. </blockquote>
  1087. <hr>
  1088. <h2><a name="fixcrlf">FixCRLF</a></h2>
  1089. <h3>Description</h3>
  1090. <p>Adjusts a text file to local.</p>
  1091. <p>The <i>basedir</i> attribute is the reference directory from where to jar.</p>
  1092. <h3>Parameters</h3>
  1093. <table border="1" cellpadding="2" cellspacing="0">
  1094. <tr>
  1095. <td valign="top"><b>Attribute</b></td>
  1096. <td valign="top"><b>Description</b></td>
  1097. <td align="center" valign="top"><b>Required</b></td>
  1098. </tr>
  1099. <tr>
  1100. <td valign="top">srcDir</td>
  1101. <td valign="top">Where to find the files to be fixed up.</td>
  1102. <td valign="top" align="center">Yes</td>
  1103. </tr>
  1104. <tr>
  1105. <td valign="top">destDir</td>
  1106. <td valign="top">Where to place the corrected files. Defaults to
  1107. srcDir (replacing the original file)</td>
  1108. <td valign="top" align="center">No</td>
  1109. </tr>
  1110. <tr>
  1111. <td valign="top">includes</td>
  1112. <td valign="top">comma separated list of patterns of files that must be
  1113. included. All files are included when omitted.</td>
  1114. <td valign="top" align="center">No</td>
  1115. </tr>
  1116. <tr>
  1117. <td valign="top">excludes</td>
  1118. <td valign="top">comma separated list of patterns of files that must be
  1119. excluded. No files (except default excludes) are excluded when omitted.</td>
  1120. <td valign="top" align="center">No</td>
  1121. </tr>
  1122. <tr>
  1123. <td valign="top">cr</td>
  1124. <td valign="top">Specifies how carriage return (CR) characters are to
  1125. be handled. Valid values for this property are:
  1126. <ul>
  1127. <li>add: ensure that there is a CR before every LF
  1128. <li>asis: leave CR characters alone
  1129. <li>remove: remove all CR characters
  1130. </ul>
  1131. Default is based on the platform on which you are running this task.
  1132. For Unix platforms, the default is remove. For DOS based systems
  1133. (including Windows), the default is add.
  1134. <p>
  1135. Note: Unless this property is specified as "asis", extra CR characters
  1136. which do not preceed a LF will be removed.
  1137. </td>
  1138. <td valign="top" align="center">No</td>
  1139. </tr>
  1140. <tr>
  1141. <td valign="top">tab</td>
  1142. <td valign="top">Specifies how tab characters are to be handled. Valid
  1143. values for this property are:
  1144. <ul>
  1145. <li>add: convert sequences of spaces which span a tab stop to tabs
  1146. <li>asis: leave tab and space characters alone
  1147. <li>remove: convert tabs to spaces
  1148. </ul>
  1149. Default for this parameter is "asis".
  1150. <p>
  1151. Note: Unless this property is specified as "asis", extra spaces and
  1152. tabs after the last non-whitespace character on the line will be removed.
  1153. </td>
  1154. <td valign="top" align="center">No</td>
  1155. </tr>
  1156. <tr>
  1157. <td valign="top">eof</td>
  1158. <td valign="top">Specifies how DOS end of file (control-Z) characters are
  1159. to be handled. Valid values for this property are:
  1160. <ul>
  1161. <li>add: ensure that there is an EOF character at the end of the file
  1162. <li>asis: leave EOF characters alone
  1163. <li>remove: remove any EOF character found at the end
  1164. </ul>
  1165. Default is based on the platform on which you are running this task.
  1166. For Unix platforms, the default is remove. For DOS based systems
  1167. (including Windows), the default is asis.
  1168. </td>
  1169. <td valign="top" align="center">No</td>
  1170. </tr>
  1171. </table>
  1172. <h3>Examples</h3>
  1173. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  1174. cr=&quot;remove&quot; eof=&quot;remove&quot;
  1175. includes=&quot;**/*.sh&quot;
  1176. /&gt;</pre>
  1177. <p>Removes carriage return and eof characters from the shell scripts. Tabs and
  1178. spaces are left as is.
  1179. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  1180. cr=&quot;add&quot;
  1181. includes=&quot;**/*.bat&quot;
  1182. /&gt;</pre>
  1183. <p>Ensures that there are carriage return characters prior to evey line feed.
  1184. Tabs and spaces are left as is.
  1185. EOF characters are left alone if run on
  1186. DOS systems, and are removed if run on Unix systems.</p>
  1187. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  1188. tabs=&quot;add&quot;
  1189. includes=&quot;**/Makefile&quot;
  1190. /&gt;</pre>
  1191. <p>Adds or removes CR characters to match local OS conventions, and
  1192. converts spaces to tabs when appropriate. EOF characters are left alone if
  1193. run on DOS systems, and are removed if run on Unix systems.
  1194. Many versions of make require tabs prior to commands.</p>
  1195. <pre> &lt;fixcrlf srcdir=&quot;${src}&quot;
  1196. tabs=&quot;remove&quot;
  1197. includes=&quot;**/README*&quot;
  1198. /&gt;</pre>
  1199. <p>Adds or removes CR characters to match local OS conventions, and
  1200. converts all tabs to spaces. EOF characters are left alone if run on
  1201. DOS systems, and are removed if run on Unix systems.
  1202. You never know what editor a user will use to browse README's.</p>
  1203. <hr>
  1204. <h2><a name="jar">Jar</a></h2>
  1205. <h3>Description</h3>
  1206. <p>Jars a set of files.</p>
  1207. <p>The <i>basedir</i> attribute is the reference directory from where to jar.</p>
  1208. <p>It is possible to refine the set of files that are being jarred. This can be
  1209. done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  1210. attributes. With the <i>includes</i> attribute you specify the files you want to
  1211. have included by using patterns. The <i>exclude</i> attribute is used to specify
  1212. the files you want to have excluded. This is also done with patterns. And
  1213. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  1214. want to use default exclusions or not. See the section on <a
  1215. href="#directorybasedtasks">directory based tasks</a>, on how the
  1216. inclusion/exclusion of files works, and how to write patterns. The patterns are
  1217. relative to the <i>basedir</i> directory.</p>
  1218. <p>The <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i> attributes
  1219. replace the <i>items</i> and <i>ignore</i> attributes. The following explains
  1220. how the deprecated <i>items</i> and <i>ignore</i> attribute behave.</p>
  1221. <p>When &quot;*&quot; is used for <i>items</i>, all files in the basedir, and
  1222. its subdirectories, will be jarred. Otherwise all the files and directories
  1223. mentioned in the items list will jarred. When a directory is specified, then all
  1224. files within it are also jarred.</p>
  1225. <p>With the <i>ignore</i> attribute, you can specify files or directories to
  1226. ignore. These files will not be jarred. The items in the <i>ignore</i> attribute
  1227. override the items in the <i>items</i> attribute. The names specified in the <i>ignore</i>
  1228. attribute are just names, they do not contain any path information!</p>
  1229. <h3>Parameters</h3>
  1230. <table border="1" cellpadding="2" cellspacing="0">
  1231. <tr>
  1232. <td valign="top"><b>Attribute</b></td>
  1233. <td valign="top"><b>Description</b></td>
  1234. <td align="center" valign="top"><b>Required</b></td>
  1235. </tr>
  1236. <tr>
  1237. <td valign="top">jarfile</td>
  1238. <td valign="top">the jar-file to create.</td>
  1239. <td valign="top" align="center">Yes</td>
  1240. </tr>
  1241. <tr>
  1242. <td valign="top">basedir</td>
  1243. <td valign="top">the directory from which to jar the files.</td>
  1244. <td valign="top" align="center">Yes</td>
  1245. </tr>
  1246. <tr>
  1247. <td valign="top">compress</td>
  1248. <td valign="top">Not only store data but also compress them, defaults to true</td>
  1249. <td align="center" valign="top">No</td>
  1250. </tr>
  1251. <tr>
  1252. <td valign="top">items</td>
  1253. <td valign="top">a comma separated list of the files/directories to jar. All
  1254. files are included when omitted. (<b>deprecated</b>, use <i>includes</i>
  1255. instead).</td>
  1256. <td valign="top" align="center">No</td>
  1257. </tr>
  1258. <tr>
  1259. <td valign="top">ignore</td>
  1260. <td valign="top">comma separated list of filenames/directorynames to exclude
  1261. from the jar. No files (except default excludes) are excluded when
  1262. omitted. (<b>deprecated</b>, use <i>excludes</i> instead).</td>
  1263. <td valign="top" align="center">No</td>
  1264. </tr>
  1265. <tr>
  1266. <td valign="top">includes</td>
  1267. <td valign="top">comma separated list of patterns of files that must be
  1268. included. All files are included when omitted.</td>
  1269. <td valign="top" align="center">No</td>
  1270. </tr>
  1271. <tr>
  1272. <td valign="top">excludes</td>
  1273. <td valign="top">comma separated list of patterns of files that must be
  1274. excluded. No files (except default excludes) are excluded when omitted.</td>
  1275. <td valign="top" align="center">No</td>
  1276. </tr>
  1277. <tr>
  1278. <td valign="top">defaultexcludes</td>
  1279. <td valign="top">indicates whether default excludes should be used or not
  1280. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  1281. <td valign="top" align="center">No</td>
  1282. </tr>
  1283. <tr>
  1284. <td valign="top">manifest</td>
  1285. <td valign="top">the manifest file to use.</td>
  1286. <td valign="top" align="center">No</td>
  1287. </tr>
  1288. </table>
  1289. <h3>Examples</h3>
  1290. <pre> &lt;jar jarfile=&quot;${dist}/lib/app.jar&quot; basedir=&quot;${build}/classes&quot; /&gt;</pre>
  1291. <p>jars all files in the <code>${build}/classes</code> directory in a file
  1292. called <code>app.jar</code> in the <code>${dist}/lib</code> directory.</p>
  1293. <pre> &lt;jar jarfile=&quot;${dist}/lib/app.jar&quot;
  1294. basedir=&quot;${build}/classes&quot;
  1295. excludes=&quot;**/Test.class&quot;
  1296. /&gt;</pre>
  1297. <p>jars all files in the <code>${build}/classes</code> directory in a file
  1298. called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Files
  1299. with the name <code>Test.class</code> are excluded.</p>
  1300. <pre> &lt;jar jarfile=&quot;${dist}/lib/app.jar&quot;
  1301. basedir=&quot;${build}/classes&quot;
  1302. includes=&quot;mypackage/test/**&quot;
  1303. excludes=&quot;**/Test.class&quot;
  1304. /&gt;</pre>
  1305. <p>jars all files in the <code>${build}/classes</code> directory in a file
  1306. called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Only
  1307. files under the directory <code>mypackage/test</code> are used, and files with
  1308. the name <code>Test.class</code> are excluded.</p>
  1309. <h3>Deprecated examples</h3>
  1310. <pre> &lt;jar jarfile=&quot;${dist}/lib/app.jar&quot; basedir=&quot;${build}/classes&quot; items=&quot;*&quot; /&gt;</pre>
  1311. <p>jars all files in the <code>${build}/classes</code> directory in a file
  1312. called <code>app.jar</code> in the <code>${dist}/lib</code> directory.</p>
  1313. <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>
  1314. <p>jars all files in the <code>${build}/classes</code> directory in a file
  1315. called <code>app.jar</code> in the <code>${dist}/lib</code> directory.
  1316. Files/directories with the name <code>Test.class</code> are excluded.</p>
  1317. <hr>
  1318. <h2><a name="java">Java</a></h2>
  1319. <h3>Description</h3>
  1320. <p>Executes a Java class within the running (Ant) VM or forks another VM if
  1321. specified.</p>
  1322. <p>Be careful that the executed class doesn't call System.exit(), because it
  1323. will terminate the VM and thus Ant. In case this happens, it's highly suggested
  1324. that you set the fork attribute so that System.exit() stops the other VM and not
  1325. the one that is currently running Ant.</p>
  1326. <h3>Parameters</h3>
  1327. <table border="1" cellpadding="2" cellspacing="0">
  1328. <tr>
  1329. <td valign="top"><b>Attribute</b></td>
  1330. <td valign="top"><b>Description</b></td>
  1331. <td align="center" valign="top"><b>Required</b></td>
  1332. </tr>
  1333. <tr>
  1334. <td valign="top">classname</td>
  1335. <td valign="top">the Java class to execute.</td>
  1336. <td align="center" valign="top">Yes</td>
  1337. </tr>
  1338. <tr>
  1339. <td valign="top">args</td>
  1340. <td valign="top">the arguments for the class that is executed.</td>
  1341. <td align="center" valign="top">No</td>
  1342. </tr>
  1343. <tr>
  1344. <td valign="top">fork</td>
  1345. <td valign="top">if enabled triggers the class execution in another VM
  1346. (disabled by default)</td>
  1347. <td align="center" valign="top">No</td>
  1348. </tr>
  1349. <tr>
  1350. <td valign="top">jvmargs</td>
  1351. <td valign="top">the arguments to pass to the forked VM (ignored if fork is
  1352. disabled)</td>
  1353. <td align="center" valign="top">No</td>
  1354. </tr>
  1355. </table>
  1356. <h3>Examples</h3>
  1357. <pre> &lt;java classname=&quot;test.Main&quot; /&gt;</pre>
  1358. <pre> &lt;java classname=&quot;test.Main&quot; args=&quot;-h&quot; /&gt;</pre>
  1359. <pre> &lt;java classname=&quot;test.Main&quot;
  1360. args=&quot;-h&quot;
  1361. fork=&quot;yes&quot;
  1362. jvmargs=&quot;-Xrunhprof:cpu=samples,file=log.txt,depth=3&quot;
  1363. /&gt;</pre>
  1364. <hr>
  1365. <h2><a name="javac">Javac</a></h2>
  1366. <h3>Description</h3>
  1367. <p>Compiles a source tree within the running (Ant) VM.</p>
  1368. <p>The source and destination directory will be recursively scanned for Java
  1369. source files to compile. Only Java files that have no corresponding class file
  1370. or where the class file is older than the java file will be compiled.</p>
  1371. <p>Files in the source tree, that are no java files, are copied to the
  1372. destination directory, allowing support files to be located properly in the
  1373. classpath.</p>
  1374. <p>The directory structure of the source tree should follow the package
  1375. hierarchy.</p>
  1376. <p>It is possible to refine the set of files that are being compiled/copied.
  1377. This can be done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  1378. attributes. With the <i>includes</i> attribute you specify the files you want to
  1379. have included by using patterns. The <i>exclude</i> attribute is used to specify
  1380. the files you want to have excluded. This is also done with patterns. And
  1381. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  1382. want to use default exclusions or not. See the section on <a
  1383. href="#directorybasedtasks">directory based tasks</a>, on how the
  1384. inclusion/exclusion of files works, and how to write patterns. The patterns are
  1385. relative to the <i>srcdir</i> directory.</p>
  1386. <p>It is possible to use different compilers. This can be selected with the
  1387. &quot;build.compiler&quot; property. There are three choices:</p>
  1388. <ul>
  1389. <li>classic (the standard compiler of JDK 1.1/1.2)</li>
  1390. <li>modern (the new compiler of JDK 1.3)</li>
  1391. <li>jikes (the <a
  1392. href="http://oss.software.ibm.com/developerworks/opensource/jikes/project">Jikes</a>
  1393. compiler)</li>
  1394. </ul>
  1395. <p>For JDK 1.1/1.2 is classic the default. For JDK 1.3 is modern the default.</p>
  1396. <h3>Parameters</h3>
  1397. <table border="1" cellpadding="2" cellspacing="0">
  1398. <tr>
  1399. <td valign="top"><b>Attribute</b></td>
  1400. <td valign="top"><b>Description</b></td>
  1401. <td align="center" valign="top"><b>Required</b></td>
  1402. </tr>
  1403. <tr>
  1404. <td valign="top">srcdir</td>
  1405. <td valign="top">location of the java files.</td>
  1406. <td align="center" valign="top">Yes</td>
  1407. </tr>
  1408. <tr>
  1409. <td valign="top">destdir</td>
  1410. <td valign="top">location where to store the class files.</td>
  1411. <td align="center" valign="top">Yes</td>
  1412. </tr>
  1413. <tr>
  1414. <td valign="top">includes</td>
  1415. <td valign="top">comma separated list of patterns of files that must be
  1416. included. All files are included when omitted.</td>
  1417. <td valign="top" align="center">No</td>
  1418. </tr>
  1419. <tr>
  1420. <td valign="top">excludes</td>
  1421. <td valign="top">comma separated list of patterns of files that must be
  1422. excluded. No files (except default excludes) are excluded when omitted.</td>
  1423. <td valign="top" align="center">No</td>
  1424. </tr>
  1425. <tr>
  1426. <td valign="top">defaultexcludes</td>
  1427. <td valign="top">indicates whether default excludes should be used or not
  1428. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  1429. <td valign="top" align="center">No</td>
  1430. </tr>
  1431. <tr>
  1432. <td valign="top">classpath</td>
  1433. <td valign="top">the classpath to use.</td>
  1434. <td align="center" valign="top">No</td>
  1435. </tr>
  1436. <tr>
  1437. <td valign="top">bootclasspath</td>
  1438. <td valign="top">location of bootstrap class files.</td>
  1439. <td align="center" valign="top">No</td>
  1440. </tr>
  1441. <tr>
  1442. <td valign="top">extdirs</td>
  1443. <td valign="top">location of installed extensions.</td>
  1444. <td align="center" valign="top">No</td>
  1445. </tr>
  1446. <tr>
  1447. <td valign="top">debug</td>
  1448. <td valign="top">indicates whether there should be compiled with debug
  1449. information (&quot;on&quot;).</td>
  1450. <td align="center" valign="top">No</td>
  1451. </tr>
  1452. <tr>
  1453. <td valign="top">optimize</td>
  1454. <td valign="top">indicates whether there should be compiled with
  1455. optimization (&quot;on&quot;).</td>
  1456. <td align="center" valign="top">No</td>
  1457. </tr>
  1458. <tr>
  1459. <td valign="top">deprecation</td>
  1460. <td valign="top">indicates whether there should be compiled with deprecation
  1461. information (&quot;on&quot;).</td>
  1462. <td align="center" valign="top">No</td>
  1463. </tr>
  1464. <tr>
  1465. <td valign="top">filtering</td>
  1466. <td valign="top">indicates whether token filtering should take place</td>
  1467. <td valign="top" align="center">No</td>
  1468. </tr>
  1469. </table>
  1470. <h3>Examples</h3>
  1471. <pre> &lt;javac srcdir=&quot;${src}&quot;
  1472. destdir=&quot;${build}&quot;
  1473. classpath=&quot;xyz.jar&quot;
  1474. debug=&quot;on&quot;
  1475. /&gt;</pre>
  1476. <p>compiles all .java files under the directory <code>${src}</code>, and stores
  1477. the .class files in the directory <code>${build}</code>. It also copies the non-java
  1478. files from the tree under <code>${src}</code> to the tree under <code>${build}</code>.
  1479. The classpath used contains <code>xyz.jar</code>, and debug information is on.</p>
  1480. <pre> &lt;javac srcdir=&quot;${src}&quot;
  1481. destdir=&quot;${build}&quot;
  1482. includes=&quot;mypackage/p1/**,mypackage/p2/**&quot;
  1483. excludes=&quot;mypackage/p1/testpackage/**&quot;
  1484. classpath=&quot;xyz.jar&quot;
  1485. debug=&quot;on&quot;
  1486. /&gt;</pre>
  1487. <p>compiles .java files under the directory <code>${src}</code>, and stores the
  1488. .class files in the directory <code>${build}</code>. It also copies the non-java
  1489. files from the tree under <code>${src}</code> to the tree under <code>${build}</code>.
  1490. The classpath used contains <code>xyz.jar</code>, and debug information is on.
  1491. Only files under <code>mypackage/p1</code> and <code>mypackage/p2</code> are
  1492. used. Files in the <code>mypackage/p1/testpackage</code> directory are excluded
  1493. form compilation and copy.</p>
  1494. <hr>
  1495. <h2><a name="javadoc">Javadoc/Javadoc2</a></h2>
  1496. <h3>Description</h3>
  1497. <p>Generates code documentation using the javadoc tool.</p>
  1498. <p>The source directory will be recursively scanned for Java source files to but
  1499. only those matching the inclusion rules will be passed to the javadoc tool. This
  1500. allows wildcards to be used to choose between package names, reducing verbosity
  1501. and management costs over time. This task, however, has no notion of
  1502. &quot;changed&quot; files, unlike the <a href="#javac">javac</a> task, but it's
  1503. not used so frequently.</p>
  1504. <p>This task works seamlessly between different javadoc versions (1.1 and 1.2),
  1505. with the obvious restriction that the 1.2 attributes will be ignored if run in a
  1506. 1.1 VM.</p>
  1507. <p>NOTE: since javadoc calls System.exit(), we cannot run javadoc inside the
  1508. same VM without breaking functionality. For this reason, this task always forks
  1509. the VM. But this is not a performance penalty since javadoc is normally a heavy
  1510. application and must be called just once.</p>
  1511. <p>DEPRECATION: the javadoc2 task simply points to the javadoc task and it's
  1512. there for back compatibility reasons. Since this task will be removed in future
  1513. versions, you are strongly encouraged to use <a href="#javadoc">javadoc</a>
  1514. instead.</p>
  1515. <h3>Parameters</h3>
  1516. <table border="1" cellpadding="2" cellspacing="0">
  1517. <tr>
  1518. <td valign="top"><b>Attribute</b></td>
  1519. <td valign="top"><b>Description</b></td>
  1520. <td align="center" valign="top"><b>Availability</b></td>
  1521. <td align="center" valign="top"><b>Required</b></td>
  1522. </tr>
  1523. <tr>
  1524. <td valign="top">sourcepath</td>
  1525. <td valign="top">Specify where to find source files</td>
  1526. <td align="center" valign="top">all</td>
  1527. <td align="center" valign="top">Yes</td>
  1528. </tr>
  1529. <tr>
  1530. <td valign="top">destdir</td>
  1531. <td valign="top">Destination directory for output files</td>
  1532. <td align="center" valign="top">all</td>
  1533. <td align="center" valign="top">Yes</td>
  1534. </tr>
  1535. <tr>
  1536. <td valign="top">sourcefiles</td>
  1537. <td valign="top">Space separated list of source files</td>
  1538. <td align="center" valign="top">all</td>
  1539. <td align="center" valign="middle" rowspan="2">at least one of the two</td>
  1540. </tr>
  1541. <tr>
  1542. <td valign="top">packagenames</td>
  1543. <td valign="top">Space separated list of package files (with terminating
  1544. wildcard)</td>
  1545. <td align="center" valign="top">all</td>
  1546. </tr>
  1547. <tr>
  1548. <td valign="top">Classpath</td>
  1549. <td valign="top">Specify where to find user class files</td>
  1550. <td align="center" valign="top">all</td>
  1551. <td align="center" valign="top">No</td>
  1552. </tr>
  1553. <tr>
  1554. <td valign="top">Bootclasspath</td>
  1555. <td valign="top">Override location of class files loaded by the bootstrap
  1556. class loader</td>
  1557. <td align="center" valign="top">1.2</td>
  1558. <td align="center" valign="top">No</td>
  1559. </tr>
  1560. <tr>
  1561. <td valign="top">Extdirs</td>
  1562. <td valign="top">Override location of installed extensions</td>
  1563. <td align="center" valign="top">1.2</td>
  1564. <td align="center" valign="top">No</td>
  1565. </tr>
  1566. <tr>
  1567. <td valign="top">Overview</td>
  1568. <td valign="top">Read overview documentation from HTML file</td>
  1569. <td align="center" valign="top">1.2</td>
  1570. <td align="center" valign="top">No</td>
  1571. </tr>
  1572. <tr>
  1573. <td valign="top">Public</td>
  1574. <td valign="top">Show only public 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">Protected</td>
  1580. <td valign="top">Show protected/public classes and members (default)</td>
  1581. <td align="center" valign="top">all</td>
  1582. <td align="center" valign="top">No</td>
  1583. </tr>
  1584. <tr>
  1585. <td valign="top">Package</td>
  1586. <td valign="top">Show package/protected/public classes and members</td>
  1587. <td align="center" valign="top">all</td>
  1588. <td align="center" valign="top">No</td>
  1589. </tr>
  1590. <tr>
  1591. <td valign="top">Private</td>
  1592. <td valign="top">Show all classes and members</td>
  1593. <td align="center" valign="top">all</td>
  1594. <td align="center" valign="top">No</td>
  1595. </tr>
  1596. <tr>
  1597. <td valign="top">Old</td>
  1598. <td valign="top">Generate output using JDK 1.1 emulating doclet</td>
  1599. <td align="center" valign="top">1.2</td>
  1600. <td align="center" valign="top">No</td>
  1601. </tr>
  1602. <tr>
  1603. <td valign="top">Verbose</td>
  1604. <td valign="top">Output messages about what Javadoc is doing</td>
  1605. <td align="center" valign="top">1.2</td>
  1606. <td align="center" valign="top">No</td>
  1607. </tr>
  1608. <tr>
  1609. <td valign="top">Locale</td>
  1610. <td valign="top">Locale to be used, e.g. en_US or en_US_WIN</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">Encoding</td>
  1616. <td valign="top">Source file encoding name</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">Version</td>
  1622. <td valign="top">Include @version paragraphs</td>
  1623. <td align="center" valign="top">all</td>
  1624. <td align="center" valign="top">No</td>
  1625. </tr>
  1626. <tr>
  1627. <td valign="top">Use</td>
  1628. <td valign="top">Create class and package usage pages</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">Author</td>
  1634. <td valign="top">Include @author paragraphs</td>
  1635. <td align="center" valign="top">all</td>
  1636. <td align="center" valign="top">No</td>
  1637. </tr>
  1638. <tr>
  1639. <td valign="top">Splitindex</td>
  1640. <td valign="top">Split index into one file per letter</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">Windowtitle</td>
  1646. <td valign="top">Browser window title for the documenation (text)</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">Doctitle</td>
  1652. <td valign="top">Include title for the package index(first) 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">Header</td>
  1658. <td valign="top">Include header text for each page (html-code)</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">Footer</td>
  1664. <td valign="top">Include footer text for each page (html-code)</td>
  1665. <td align="center" valign="top">1.2</td>
  1666. <td align="center" valign="top">No</td>
  1667. </tr>
  1668. <tr>
  1669. <td valign="top">bottom</td>
  1670. <td valign="top">Include bottom text for each page (html-code)</td>
  1671. <td align="center" valign="top">1.2</td>
  1672. <td align="center" valign="top">No</td>
  1673. </tr>
  1674. <tr>
  1675. <td valign="top">link</td>
  1676. <td valign="top">Create links to javadoc output at the given URL</td>
  1677. <td align="center" valign="top">1.2</td>
  1678. <td align="center" valign="top">No</td>
  1679. </tr>
  1680. <tr>
  1681. <td valign="top">linkoffline</td>
  1682. <td valign="top">Link to docs at &lt;url&gt; using package list at
  1683. &lt;url2&gt;</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">group</td>
  1689. <td valign="top">Group specified packages together in overview page</td>
  1690. <td align="center" valign="top">1.2</td>
  1691. <td align="center" valign="top">No</td>
  1692. </tr>
  1693. <tr>
  1694. <td valign="top">nodeprecated</td>
  1695. <td valign="top">Do not include @deprecated information</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">nodeprecatedlist</td>
  1701. <td valign="top">Do not generate deprecated list</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">notree</td>
  1707. <td valign="top">Do not generate class hierarchy</td>
  1708. <td align="center" valign="top">all</td>
  1709. <td align="center" valign="top">No</td>
  1710. </tr>
  1711. <tr>
  1712. <td valign="top">noindex</td>
  1713. <td valign="top">Do not generate index</td>
  1714. <td align="center" valign="top">all</td>
  1715. <td align="center" valign="top">No</td>
  1716. </tr>
  1717. <tr>
  1718. <td valign="top">nohelp</td>
  1719. <td valign="top">Do not generate help link</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">nonavbar</td>
  1725. <td valign="top">Do not generate navigation bar</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">serialwarn</td>
  1731. <td valign="top">Generate warning about @serial tag</td>
  1732. <td align="center" valign="top">1.2</td>
  1733. <td align="center" valign="top">No</td>
  1734. </tr>
  1735. <tr>
  1736. <td valign="top">helpfile</td>
  1737. <td valign="top">Specifies the HTML help file to use</td>
  1738. <td align="center" valign="top">1.2</td>
  1739. <td align="center" valign="top">No</td>
  1740. </tr>
  1741. <tr>
  1742. <td valign="top">stylesheetfile</td>
  1743. <td valign="top">Specifies the CSS stylesheet to use</td>
  1744. <td align="center" valign="top">1.2</td>
  1745. <td align="center" valign="top">No</td>
  1746. </tr>
  1747. <tr>
  1748. <td valign="top">charset</td>
  1749. <td valign="top">Charset for cross-platform viewing of generated
  1750. documentation</td>
  1751. <td align="center" valign="top">1.2</td>
  1752. <td align="center" valign="top">No</td>
  1753. </tr>
  1754. <tr>
  1755. <td valign="top">docencoding</td>
  1756. <td valign="top">Output file encoding name</td>
  1757. <td align="center" valign="top">1.1</td>
  1758. <td align="center" valign="top">No</td>
  1759. </tr>
  1760. </table>
  1761. <h3>Example</h3>
  1762. <pre> &lt;javadoc packagenames=&quot;com.dummy.test.*&quot;
  1763. sourcepath=&quot;src&quot;
  1764. destdir=&quot;docs/api&quot;
  1765. author=&quot;true&quot;
  1766. version=&quot;true&quot;
  1767. use=&quot;true&quot;
  1768. windowtitle=&quot;Test API&quot;
  1769. doctitle=&quot;&lt;h1&gt;Test&lt;/h1&gt;&quot;
  1770. bottom=&quot;&lt;i&gt;Copyright &amp;#169; 2000 Dummy Corp. All Rights Reserved.&lt;/i&gt;&quot;
  1771. /&gt;</pre>
  1772. <hr>
  1773. <h2><a name="keysubst">KeySubst</a></h2>
  1774. <h3>Description</h3>
  1775. <p>Performs keyword substitution in the source file, and writes the result to
  1776. the destination file.</p>
  1777. <p>Keys in the source file are of the form ${keyname}. The <i>keys</i> attribute
  1778. contains key/value pairs. When a key is found in the <i>keys</i> attribute, then
  1779. &quot;${keyname}&quot; is replaced by the corresponding value.</p>
  1780. <p>The <i>keys</i> attribute is of the form
  1781. &quot;name1=value1*name2=value2*name3=value3&quot;. The '*' is called the
  1782. separator, which might we changed with the <i>sep</i> attribute.</p>
  1783. <p>Note: the source file and destination file may not be the same.</p>
  1784. <h3>Parameters</h3>
  1785. <table border="1" cellpadding="2" cellspacing="0">
  1786. <tr>
  1787. <td valign="top"><b>Attribute</b></td>
  1788. <td valign="top"><b>Description</b></td>
  1789. <td align="center" valign="top"><b>Required</b></td>
  1790. </tr>
  1791. <tr>
  1792. <td valign="top">src</td>
  1793. <td valign="top">the source file.</td>
  1794. <td align="center" valign="top">Yes</td>
  1795. </tr>
  1796. <tr>
  1797. <td valign="top">dest</td>
  1798. <td valign="top">the destination file.</td>
  1799. <td align="center" valign="top">Yes</td>
  1800. </tr>
  1801. <tr>
  1802. <td valign="top">sep</td>
  1803. <td valign="top">the separator for the name/value pairs.</td>
  1804. <td align="center" valign="top">No</td>
  1805. </tr>
  1806. <tr>
  1807. <td valign="top">keys</td>
  1808. <td valign="top">name/value pairs for replacement.</td>
  1809. <td align="center" valign="top">Yes</td>
  1810. </tr>
  1811. </table>
  1812. <h3>Examples</h3>
  1813. <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>
  1814. <hr>
  1815. <h2><a name="mkdir">Mkdir</a></h2>
  1816. <h3>Description</h3>
  1817. <p>Creates a directory. Also non-existent parent directories are created, when
  1818. necessary.</p>
  1819. <h3>Parameters</h3>
  1820. <table border="1" cellpadding="2" cellspacing="0">
  1821. <tr>
  1822. <td valign="top"><b>Attribute</b></td>
  1823. <td valign="top"><b>Description</b></td>
  1824. <td align="center" valign="top"><b>Required</b></td>
  1825. </tr>
  1826. <tr>
  1827. <td valign="top">dir</td>
  1828. <td valign="top">the directory to create.</td>
  1829. <td align="center" valign="top">Yes</td>
  1830. </tr>
  1831. </table>
  1832. <h3>Examples</h3>
  1833. <pre>&lt;mkdir dir=&quot;${dist}&quot; /&gt;</pre>
  1834. <p>creates a directory <code>${dist}</code>.</p>
  1835. <pre>&lt;mkdir dir=&quot;${dist}/lib&quot; /&gt;</pre>
  1836. <p>creates a directory <code>${dist}/lib</code>.</p>
  1837. <hr>
  1838. <h2><a name="property">Property</a></h2>
  1839. <h3>Description</h3>
  1840. <p>Sets a property (by name and value), or set of properties (from file or
  1841. resource) in the project.</p>
  1842. <p>When a property was set by the user, or was a property in a parent project
  1843. (that started this project with the <a href="#ant">ant task</a>), then this
  1844. property cannot be set, and will be ignored. This means that properties set
  1845. outside the current project always override the properties of the current
  1846. project.</p>
  1847. <p>There are three ways to set properties:</p>
  1848. <ul>
  1849. <li>By supplying both the <i>name</i> and <i>value</i> attribute.</li>
  1850. <li>By setting the <i>file</i> attribute with the filename of the property
  1851. file to load. This property file has the format as defined by the file used
  1852. in the class java.util.Properties.</li>
  1853. <li>By setting the <i>resource</i> attribute with the resource name of the
  1854. property file to load. This property file has the format as defined by the
  1855. file used in the class java.util.Properties.</li>
  1856. </ul>
  1857. <p>Although combinations of the three ways are possible, only one should be used
  1858. at a time. Problems might occur with the order in which properties are set, for
  1859. instance.</p>
  1860. <p>The value part of the properties being set, might contain references to other
  1861. properties. These references are resolved at the time these properties are set.
  1862. This also holds for properties loaded from a property file.</p>
  1863. <h3>Parameters</h3>
  1864. <table border="1" cellpadding="2" cellspacing="0">
  1865. <tr>
  1866. <td valign="top"><b>Attribute</b></td>
  1867. <td valign="top"><b>Description</b></td>
  1868. <td align="center" valign="top"><b>Required</b></td>
  1869. </tr>
  1870. <tr>
  1871. <td valign="top">name</td>
  1872. <td valign="top">the name of the property to set.</td>
  1873. <td valign="top" align="center">Yes</td>
  1874. </tr>
  1875. <tr>
  1876. <td valign="top">value</td>
  1877. <td valign="top">the value of the property.</td>
  1878. <td valign="middle" align="center" rowspan="3">Yes</td>
  1879. </tr>
  1880. <tr>
  1881. <td valign="top">resource</td>
  1882. <td valign="top">the resource name of the property file.</td>
  1883. </tr>
  1884. <tr>
  1885. <td valign="top">file</td>
  1886. <td valign="top">the filename of the property file .</td>
  1887. </tr>
  1888. </table>
  1889. <h3>Examples</h3>
  1890. <pre> &lt;property name=&quot;foo.dist&quot; value=&quot;dist&quot; /&gt;</pre>
  1891. <p>sets the property <code>foo.dist</code> to the value &quot;dist&quot;.</p>
  1892. <pre> &lt;property file=&quot;foo.properties&quot; /&gt;</pre>
  1893. <p>reads a set of properties from a file called &quot;foo.properties&quot;.</p>
  1894. <pre> &lt;property resource=&quot;foo.properties&quot; /&gt;</pre>
  1895. <p>reads a set of properties from a resource called &quot;foo.properties&quot;.</p>
  1896. <hr>
  1897. <h2><a name="rename">Rename</a></h2>
  1898. <h3>Description</h3>
  1899. <p>Renames a given file.</p>
  1900. <h3>Parameters</h3>
  1901. <table border="1" cellpadding="2" cellspacing="0">
  1902. <tr>
  1903. <td valign="top"><b>Attribute</b></td>
  1904. <td valign="top"><b>Description</b></td>
  1905. <td align="center" valign="top"><b>Required</b></td>
  1906. </tr>
  1907. <tr>
  1908. <td valign="top">src</td>
  1909. <td valign="top">file to rename.</td>
  1910. <td valign="top" align="center">Yes</td>
  1911. </tr>
  1912. <tr>
  1913. <td valign="top">dest</td>
  1914. <td valign="top">new name of the file.</td>
  1915. <td valign="top" align="center">Yes</td>
  1916. </tr>
  1917. <tr>
  1918. <td valign="top">replace</td>
  1919. <td valign="top">Enable replacing of existing file (default: on).</td>
  1920. <td valign="top" align="center">No</td>
  1921. </tr>
  1922. </table>
  1923. <h3>Examples</h3>
  1924. <pre> &lt;rename src=&quot;foo.jar&quot; dest=&quot;${name}-${version}.jar&quot; /&gt;</pre>
  1925. <p>Renames the file <code>foo.jar</code> to <code>${name}-${version}.jar</code> (assuming <code>name</code>
  1926. and <code>version</code> being predefined properties). If a file named <code>${name}-${version}.jar</code>
  1927. already exists, it will be removed prior to renameing <code>foo.jar</code>.</p>
  1928. <hr>
  1929. <h2><a name="replace">Replace</a></h2>
  1930. <h3>Description</h3>
  1931. <p>Replaces the occurrence of a given string with another string in a file.</p>
  1932. <h3>Parameters</h3>
  1933. <table border="1" cellpadding="2" cellspacing="0">
  1934. <tr>
  1935. <td valign="top"><b>Attribute</b></td>
  1936. <td valign="top"><b>Description</b></td>
  1937. <td align="center" valign="top"><b>Required</b></td>
  1938. </tr>
  1939. <tr>
  1940. <td valign="top">file</td>
  1941. <td valign="top">file for which the token should be replaced.</td>
  1942. <td valign="top" align="center">Yes</td>
  1943. </tr>
  1944. <tr>
  1945. <td valign="top">token</td>
  1946. <td valign="top">the token which must be replaced.</td>
  1947. <td valign="top" align="center">Yes</td>
  1948. </tr>
  1949. <tr>
  1950. <td valign="top">value</td>
  1951. <td valign="top">the new value for the token. When omitted, an empty string
  1952. (&quot;&quot;) is used.</td>
  1953. <td valign="top" align="center">No</td>
  1954. </tr>
  1955. </table>
  1956. <h3>Examples</h3>
  1957. <pre> &lt;replace file=&quot;${src}/index.html&quot; token=&quot;@@@&quot; value=&quot;wombat&quot; /&gt;</pre>
  1958. <p>replaces occurrences of the string &quot;@@@&quot; with the string
  1959. &quot;wombat&quot;, in the file <code>${src}/index.html</code>.</p>
  1960. <hr>
  1961. <h2><a name="rmic">Rmic</a></h2>
  1962. <h3>Description</h3>
  1963. <p>Runs the rmic compiler for a certain class.</p>
  1964. <h3>Parameters</h3>
  1965. <table border="1" cellpadding="2" cellspacing="0">
  1966. <tr>
  1967. <td valign="top"><b>Attribute</b></td>
  1968. <td valign="top"><b>Description</b></td>
  1969. <td align="center" valign="top"><b>Required</b></td>
  1970. </tr>
  1971. <tr>
  1972. <td valign="top">base</td>
  1973. <td valign="top">the location to store the compiled files.</td>
  1974. <td valign="top" align="center">Yes</td>
  1975. </tr>
  1976. <tr>
  1977. <td valign="top">classname</td>
  1978. <td valign="top">the class for which to run <code>rmic</code>.</td>
  1979. <td valign="top" align="center">Yes</td>
  1980. </tr>
  1981. <tr>
  1982. <td valign="top">filtering</td>
  1983. <td valign="top">indicates whether token filtering should take place</td>
  1984. <td valign="top" align="center">No</td>
  1985. </tr>
  1986. </table>
  1987. <h3>Examples</h3>
  1988. <pre> &lt;rmic classname=&quot;com.xyz.FooBar&quot; base=&quot;${build}/classes&quot; /&gt;</pre>
  1989. <p>runs the rmic compiler for the class <code>com.xyz.FooBar</code>. The
  1990. compiled files will be stored in the directory <code>${build}/classes</code>.</p>
  1991. <hr>
  1992. <h2><a name="tar">Tar</a></h2>
  1993. <h3>Description</h3>
  1994. <p>Creates a tar archive.</p>
  1995. <p>The <i>basedir</i> attribute is the reference directory from where to tar.</p>
  1996. <p>It is possible to refine the set of files that are being tarred. This can be
  1997. done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  1998. attributes. With the <i>includes</i> attribute you specify the files you want to
  1999. have included by using patterns. The <i>exclude</i> attribute is used to specify
  2000. the files you want to have excluded. This is also done with patterns. And
  2001. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  2002. want to use default exclusions or not. See the section on <a
  2003. href="#directorybasedtasks">directory based tasks</a>, on how the
  2004. inclusion/exclusion of files works, and how to write patterns. The patterns are
  2005. relative to the <i>basedir</i> directory.</p>
  2006. <p>The <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i> attributes
  2007. replace the <i>items</i> and <i>ignore</i> attributes. The following explains
  2008. how the deprecated <i>items</i> and <i>ignore</i> attribute behave.</p>
  2009. <p>When &quot;*&quot; is used for <i>items</i>, all files in the basedir, and
  2010. its subdirectories, will be tarred. Otherwise all the files and directories
  2011. mentioned in the items list will tarred. When a directory is specified, then all
  2012. files within it are also tarred.</p>
  2013. <p>With the <i>ignore</i> attribute, you can specify files or directories to
  2014. ignore. These files will not be tarred. The items in the <i>ignore</i> attribute
  2015. override the items in the <i>items</i> attribute. The names specified in the <i>ignore</i>
  2016. attribute are just names, they do not contain any path information!</p>
  2017. <p>Note that this task does not perform compression. You might want to use the <a href="#gzip">GZip</a>
  2018. task to come up with a .tar.gz package.</p>
  2019. <h3>Parameters</h3>
  2020. <table border="1" cellpadding="2" cellspacing="0">
  2021. <tr>
  2022. <td valign="top"><b>Attribute</b></td>
  2023. <td valign="top"><b>Description</b></td>
  2024. <td valign="top" align="center"><b>Required</b></td>
  2025. </tr>
  2026. <tr>
  2027. <td valign="top">tarfile</td>
  2028. <td valign="top">the tar-file to create.</td>
  2029. <td align="center" valign="top">Yes</td>
  2030. </tr>
  2031. <tr>
  2032. <td valign="top">basedir</td>
  2033. <td valign="top">the directory from which to zip the files.</td>
  2034. <td align="center" valign="top">Yes</td>
  2035. </tr>
  2036. <tr>
  2037. <td valign="top">includes</td>
  2038. <td valign="top">comma separated list of patterns of files that must be
  2039. included. All files are included when omitted.</td>
  2040. <td valign="top" align="center">No</td>
  2041. </tr>
  2042. <tr>
  2043. <td valign="top">excludes</td>
  2044. <td valign="top">comma separated list of patterns of files that must be
  2045. excluded. No files (except default excludes) are excluded when omitted.</td>
  2046. <td valign="top" align="center">No</td>
  2047. </tr>
  2048. <tr>
  2049. <td valign="top">defaultexcludes</td>
  2050. <td valign="top">indicates whether default excludes should be used or not
  2051. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  2052. <td valign="top" align="center">No</td>
  2053. </tr>
  2054. </table>
  2055. <h3>Examples</h3>
  2056. <pre> &lt;tar tarfile=&quot;${dist}/manual.tar&quot; basedir=&quot;htdocs/manual&quot; /&gt;
  2057. &lt;gzip zipfile=&quot;${dist}/manual.tar.gz&quot; src=&quot;${dist}/manual.tar&quot; /&gt;</pre>
  2058. <p>tars all files in the <code>htdocs/manual</code> directory in a file called <code>manual.tar</code>
  2059. in the <code>${dist}</code> directory, then applies the gzip task to compress
  2060. it.</p>
  2061. <pre> &lt;tar tarfile=&quot;${dist}/manual.tar&quot;
  2062. basedir=&quot;htdocs/manual&quot;
  2063. excludes=&quot;mydocs/**, **/todo.html&quot;
  2064. /&gt;</pre>
  2065. <p>tars all files in the <code>htdocs/manual</code> directory in a file called <code>manual.tar</code>
  2066. in the <code>${dist}</code> directory. Files in the directory <code>mydocs</code>,
  2067. or files with the name <code>todo.html</code> are excluded.</p>
  2068. <hr>
  2069. <h2><a name="taskdef">Taskdef</a></h2>
  2070. <h3>Description</h3>
  2071. <p>Adds a task definition to the current project, such that this new task can be
  2072. used in the current project. Two attributes are needed, the name that identifies
  2073. this task uniquely, and the full name of the class (including the packages) that
  2074. implements this task.</p>
  2075. <p>Taskdef should be used to add your own tasks to the system. See also &quot;<a
  2076. href="#writingowntask">Writing your own task</a>&quot;.</p>
  2077. <h3>Parameters</h3>
  2078. <table border="1" cellpadding="2" cellspacing="0">
  2079. <tr>
  2080. <td valign="top"><b>Attribute</b></td>
  2081. <td valign="top"><b>Description</b></td>
  2082. <td align="center" valign="top"><b>Required</b></td>
  2083. </tr>
  2084. <tr>
  2085. <td valign="top">name</td>
  2086. <td valign="top">the name of the task</td>
  2087. <td valign="top" align="center">Yes</td>
  2088. </tr>
  2089. <tr>
  2090. <td valign="top">classname</td>
  2091. <td valign="top">the full class name implementing the task</td>
  2092. <td valign="top" align="center">Yes</td>
  2093. </tr>
  2094. </table>
  2095. <h3>Examples</h3>
  2096. <pre> &lt;taskdef name=&quot;myjavadoc&quot; classname=&quot;com.mydomain.JavadocTask&quot; /&gt;</pre>
  2097. <p>makes a task called <code>myjavadoc</code> available to Ant. The class <code>com.mydomain.JavadocTask</code>
  2098. implements the task.</p>
  2099. <hr>
  2100. <h2><a name="tstamp">Tstamp</a></h2>
  2101. <h3>Description</h3>
  2102. <p>Sets the DSTAMP, TSTAMP and TODAY properties in the current project. The
  2103. DSTAMP is in the &quot;yyyymmdd&quot; format, the TSTAMP is in the &quot;hhmm&quot;
  2104. format and TODAY is &quot;month day year&quot;.</p>
  2105. <p>These properties can be used in the buildfile, for instance, to create
  2106. timestamped filenames or used to replace placeholder tags inside documents to
  2107. indicate, for example, the release date. The best place for this task is in your
  2108. initialization target.</p>
  2109. <h3>Parameters</h3>
  2110. <table border="1" cellpadding="2" cellspacing="0">
  2111. <tr>
  2112. <td valign="top"><b>Attribute</b></td>
  2113. <td valign="top"><b>Description</b></td>
  2114. <td align="center" valign="top"><b>Required</b></td>
  2115. </tr>
  2116. </table>
  2117. <h3>Examples</h3>
  2118. <pre> &lt;tstamp/&gt;</pre>
  2119. <hr>
  2120. <h2><a name="untar">Untar</a></h2>
  2121. <h3>Description</h3>
  2122. <p>Untars a tarfile.</p>
  2123. <h3>Parameters</h3>
  2124. <table border="1" cellpadding="2" cellspacing="0">
  2125. <tr>
  2126. <td valign="top"><b>Attribute</b></td>
  2127. <td valign="top"><b>Description</b></td>
  2128. <td align="center" valign="top"><b>Required</b></td>
  2129. </tr>
  2130. <tr>
  2131. <td valign="top">src</td>
  2132. <td valign="top">tarfile to expand.</td>
  2133. <td align="center" valign="top">Yes</td>
  2134. </tr>
  2135. <tr>
  2136. <td valign="top">dest</td>
  2137. <td valign="top">directory where to store the expanded files.</td>
  2138. <td align="center" valign="top">Yes</td>
  2139. </tr>
  2140. </table>
  2141. <h3>Examples</h3>
  2142. <blockquote>
  2143. <p><code>
  2144. &lt;gunzip src=&quot;tools.tar.gz&quot;/&gt;<br>
  2145. &lt;untar src=&quot;tools.tar&quot; dest=&quot;${tools.home}&quot;/&gt;
  2146. </code></p>
  2147. </blockquote>
  2148. <hr>
  2149. <h2><a name="zip">Zip</a></h2>
  2150. <h3>Description</h3>
  2151. <p>Creates a zipfile.</p>
  2152. <p>The <i>basedir</i> attribute is the reference directory from where to zip.</p>
  2153. <p>It is possible to refine the set of files that are being zipped. This can be
  2154. done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  2155. attributes. With the <i>includes</i> attribute you specify the files you want to
  2156. have included by using patterns. The <i>exclude</i> attribute is used to specify
  2157. the files you want to have excluded. This is also done with patterns. And
  2158. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  2159. want to use default exclusions or not. See the section on <a
  2160. href="#directorybasedtasks">directory based tasks</a>, on how the
  2161. inclusion/exclusion of files works, and how to write patterns. The patterns are
  2162. relative to the <i>basedir</i> directory.</p>
  2163. <p>The <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i> attributes
  2164. replace the <i>items</i> and <i>ignore</i> attributes. The following explains
  2165. how the deprecated <i>items</i> and <i>ignore</i> attribute behave.</p>
  2166. <p>When &quot;*&quot; is used for <i>items</i>, all files in the basedir, and
  2167. its subdirectories, will be zipped. Otherwise all the files and directories
  2168. mentioned in the items list will zipped. When a directory is specified, then all
  2169. files within it are also zipped.</p>
  2170. <p>With the <i>ignore</i> attribute, you can specify files or directories to
  2171. ignore. These files will not be zipped. The items in the <i>ignore</i> attribute
  2172. override the items in the <i>items</i> attribute. The names specified in the <i>ignore</i>
  2173. attribute are just names, they do not contain any path information!</p>
  2174. <h3>Parameters</h3>
  2175. <table border="1" cellpadding="2" cellspacing="0">
  2176. <tr>
  2177. <td valign="top"><b>Attribute</b></td>
  2178. <td valign="top"><b>Description</b></td>
  2179. <td valign="top" align="center"><b>Required</b></td>
  2180. </tr>
  2181. <tr>
  2182. <td valign="top">zipfile</td>
  2183. <td valign="top">the zip-file to create.</td>
  2184. <td align="center" valign="top">Yes</td>
  2185. </tr>
  2186. <tr>
  2187. <td valign="top">basedir</td>
  2188. <td valign="top">the directory from which to zip the files.</td>
  2189. <td align="center" valign="top">Yes</td>
  2190. </tr>
  2191. <tr>
  2192. <td valign="top">compress</td>
  2193. <td valign="top">Not only store data but also compress them, defaults to true</td>
  2194. <td align="center" valign="top">No</td>
  2195. </tr>
  2196. <tr>
  2197. <td valign="top">items</td>
  2198. <td valign="top">a comma separated list of the files/directories to zip. All
  2199. files are included when omitted. (<b>deprecated</b>, use <i>includes</i>
  2200. instead).</td>
  2201. <td valign="top" align="center">No</td>
  2202. </tr>
  2203. <tr>
  2204. <td valign="top">ignore</td>
  2205. <td valign="top">comma separated list of filenames/directorynames to exclude
  2206. from the zip. No files (except default excludes) are excluded when
  2207. omitted. (<b>deprecated</b>, use <i>excludes</i> instead).</td>
  2208. <td valign="top" align="center">No</td>
  2209. </tr>
  2210. <tr>
  2211. <td valign="top">includes</td>
  2212. <td valign="top">comma separated list of patterns of files that must be
  2213. included. All files are included when omitted.</td>
  2214. <td valign="top" align="center">No</td>
  2215. </tr>
  2216. <tr>
  2217. <td valign="top">excludes</td>
  2218. <td valign="top">comma separated list of patterns of files that must be
  2219. excluded. No files (except default excludes) are excluded when omitted.</td>
  2220. <td valign="top" align="center">No</td>
  2221. </tr>
  2222. <tr>
  2223. <td valign="top">defaultexcludes</td>
  2224. <td valign="top">indicates whether default excludes should be used or not
  2225. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  2226. <td valign="top" align="center">No</td>
  2227. </tr>
  2228. </table>
  2229. <h3>Examples</h3>
  2230. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;
  2231. basedir=&quot;htdocs/manual&quot;
  2232. /&gt;</pre>
  2233. <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
  2234. in the <code>${dist}</code> directory.</p>
  2235. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;
  2236. basedir=&quot;htdocs/manual&quot;
  2237. excludes=&quot;mydocs/**, **/todo.html&quot;
  2238. /&gt;</pre>
  2239. <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
  2240. in the <code>${dist}</code> directory. Files in the directory <code>mydocs</code>,
  2241. or files with the name <code>todo.html</code> are excluded.</p>
  2242. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;
  2243. basedir=&quot;htdocs/manual&quot;
  2244. includes=&quot;api/**/*.html&quot;
  2245. excludes=&quot;**/todo.html&quot;
  2246. /&gt;</pre>
  2247. <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
  2248. in the <code>${dist}</code> directory. Only html files under the directory <code>api</code>
  2249. are zipped, and files with the name <code>todo.html</code> are excluded.</p>
  2250. <h3>Deprecated examples</h3>
  2251. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;
  2252. basedir=&quot;htdocs/manual&quot;
  2253. items=&quot;*&quot;
  2254. /&gt;</pre>
  2255. <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
  2256. in the <code>${dist}</code> directory.</p>
  2257. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;
  2258. basedir=&quot;htdocs/manual&quot;
  2259. items=&quot;*&quot;
  2260. ignore=&quot;mydocs, todo.html&quot;
  2261. /&gt;</pre>
  2262. <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
  2263. in the <code>${dist}</code> directory. Files/directories with the names <code>mydocs</code>
  2264. and <code>todo.html</code> are excluded.</p>
  2265. <hr>
  2266. <h2><a name="writingowntask">Writing your own task</a></h2>
  2267. <p>It is very easy to write your own task:</p>
  2268. <ol>
  2269. <li>Create a Java class that extends <code>org.apache.tools.ant.Task</code>.</li>
  2270. <li>For each attribute, write a setter method. The setter method must be a <code>public
  2271. void</code> method that takes one <code>String</code> as an argument. The
  2272. name of the method must begin with &quot;set&quot;, followed by the
  2273. attribute name, with the first character in uppercase, and the rest in
  2274. lowercase.</li>
  2275. <li>Write a <code>public void execute</code> method, with no arguments, that
  2276. throws a <code>BuildException</code>. This method implements the task
  2277. itself.</li>
  2278. </ol>
  2279. <p>It is important to know that Ant first calls the setters for the attributes
  2280. it encounters for a specific task in the buildfile, before it executes is.</p>
  2281. <p>Let's write our own task, that prints a message on the System.out stream. The
  2282. task has one attribute called &quot;message&quot;.</p>
  2283. <blockquote>
  2284. <pre>package com.mydomain;
  2285. import org.apache.tools.ant.BuildException;
  2286. import org.apache.tools.ant.Task;
  2287. public class MyVeryOwnTask extends Task {
  2288. private String msg;
  2289. // The method executing the task
  2290. public void execute() throws BuildException {
  2291. System.out.println(msg);
  2292. }
  2293. // The setter for the &quot;message&quot; attribute
  2294. public void setMessage(String msg) {
  2295. this.msg = msg;
  2296. }
  2297. }</pre>
  2298. </blockquote>
  2299. <p>It's really this simple;-)</p>
  2300. <p>Adding your task to the system is rather simple too:</p>
  2301. <ol>
  2302. <li>Make sure the class that implements your task is in the classpath when
  2303. starting Ant.</li>
  2304. <li>In your initialization target, add a <i>taskdef</i> task. This actually adds
  2305. your task to the system.</li>
  2306. <li>Use your task in the rest of the buildfile.</li>
  2307. </ol>
  2308. <h3>Example</h3>
  2309. <blockquote>
  2310. <pre>&lt;?xml version=&quot;1.0&quot;?&gt;
  2311. &lt;project name=&quot;OwnTaskExample&quot; default=&quot;main&quot; basedir=&quot;.&quot;&gt;
  2312. &lt;target name=&quot;init&quot;&gt;
  2313. &lt;taskdef name=&quot;mytask&quot; classname=&quot;com.mydomain.MyVeryOwnTask&quot;/&gt;
  2314. &lt;/target&gt;
  2315. &lt;target name=&quot;main&quot; depends=&quot;init&quot;&gt;
  2316. &lt;mytask message=&quot;Hello World! MyVeryOwnTask works!&quot; /&gt;
  2317. &lt;/target&gt;
  2318. &lt;/project&gt;
  2319. </pre>
  2320. </blockquote>
  2321. <p>Another way to add a task (more permanently), is to add the task name and
  2322. implementing class name to the <code>default.properties</code> file in the <code>org.apache.tools.ant.taskdefs</code>
  2323. package. Then you can use it as if it were a built in task.</p>
  2324. <hr>
  2325. <h2><a name="feedback">Feedback</a></h2>
  2326. <p>To provide feedback on this software, please subscribe to the Ant Development
  2327. Mail List <a href="mailto:(ant-dev-subscribe@jakarta.apache.org">(ant-dev-subscribe@jakarta.apache.org</a>)</p>
  2328. <hr>
  2329. <p align="center">Copyright � 2000 Apache Software Foundation. All rights
  2330. Reserved.</p>
  2331. <h2><a name="optionaltasks">Optional tasks</a></h2>
  2332. <ul>
  2333. <li><a href="#netrexxc">NetRexxC</a></li>
  2334. <li><a href="#renameexts">RenameExtensions</a></li>
  2335. <li><a href="#script">Script</a></li>
  2336. </ul>
  2337. <hr>
  2338. <h2><a name="netrexxc">NetRexxC</a></h2>
  2339. <h3><b>Description:</b></h3>
  2340. <p>Compiles a <a href="http://www2.hursley.ibm.com/netrexx">NetRexx</a>
  2341. source tree within the running (Ant) VM.</p>
  2342. <p>The source and destination directory will be recursively scanned for
  2343. NetRexx source files to compile. Only NetRexx files that have no corresponding
  2344. class file or where the class file is older than the java file will be compiled.</p>
  2345. <p>Files in the source tree are copied to the destination directory,
  2346. allowing support files to be located properly in the classpath. The source
  2347. files are copied because the NetRexx compiler cannot produce class files in a
  2348. specific directory via parameters</p>
  2349. <p>The directory structure of the source tree should follow the package
  2350. hierarchy.</p>
  2351. <p>It is possible to refine the set of files that are being compiled/copied.
  2352. This can be done with the <i>includes</i>, <i>excludes</i> and
  2353. <i>defaultexcludes</i> attributes. With the <i>includes</i> attribute you
  2354. specify the files you want to have included by using patterns. The
  2355. <i>exclude</i> attribute is used to specify the files you want to have
  2356. excluded. This is also done with patterns. And finally with the
  2357. <i>defaultexcludes</i> attribute, you can specify whether you
  2358. want to use default exclusions or not. See the section on <a
  2359. href="#directorybasedtasks">directory based tasks</a>, on how the
  2360. inclusion/exclusion of files works, and how to write patterns. The
  2361. patterns are relative to the <i>srcDir</i> directory.</p>
  2362. <h3>Parameters:</h3>
  2363. <table border="1" cellpadding="2" cellspacing="0">
  2364. <tr>
  2365. <td valign="top"><b>Attribute</b></td>
  2366. <td valign="top"><b>Description</b></td>
  2367. <td align="center" valign="top"><b>Required</b></td>
  2368. </tr>
  2369. <tr>
  2370. <td valign="top">binary</td>
  2371. <td valign="top">Whether literals are treated as the java binary
  2372. type rather than the NetRexx types</td>
  2373. <td valign="top" align="center">No</td>
  2374. </tr>
  2375. <tr>
  2376. <td valign="top">classpath</td>
  2377. <td valign="top">The classpath to use during compilation</td>
  2378. <td valign="top" align="center">No</td>
  2379. </tr>
  2380. <tr>
  2381. <td valign="top">comments</td>
  2382. <td valign="top">Whether comments are passed through to the
  2383. generated java source</td>
  2384. <td valign="top" align="center">No</td>
  2385. </tr>
  2386. <tr>
  2387. <td valign="top">compact</td>
  2388. <td valign="top">Whether error messages come out in compact or
  2389. verbose format</td>
  2390. <td valign="top" align="center">No</td>
  2391. </tr>
  2392. <tr>
  2393. <td valign="top">compile</td>
  2394. <td valign="top">Whether the NetRexx compiler should compile the
  2395. generated java code</td>
  2396. <td valign="top" align="center">No</td>
  2397. </tr>
  2398. <tr>
  2399. <td valign="top">console</td>
  2400. <td valign="top">Whether or not messages should be displayed on the
  2401. 'console'</td>
  2402. <td valign="top" align="center">No</td>
  2403. </tr>
  2404. <tr>
  2405. <td valign="top">crossref</td>
  2406. <td valign="top">Whether variable cross references are generated</td>
  2407. <td valign="top" align="center">No</td>
  2408. </tr>
  2409. <tr>
  2410. <td valign="top">decimal</td>
  2411. <td valign="top">Whether decimal arithmetic should be used for the
  2412. NetRexx code</td>
  2413. <td valign="top" align="center">No</td>
  2414. </tr>
  2415. <tr>
  2416. <td valign="top">defaultexcludes</td>
  2417. <td valign="top">indicates whether default excludes should be used or not
  2418. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
  2419. omitted.</td>
  2420. <td valign="top" align="center">No</td>
  2421. </tr>
  2422. <tr>
  2423. <td valign="top">destDir</td>
  2424. <td valign="top">the destination directory into which the NetRexx
  2425. source files should be copied and then compiled</td>
  2426. <td valign="top" align="center">Yes</td>
  2427. </tr>
  2428. <tr>
  2429. <td valign="top">diag</td>
  2430. <td valign="top">Whether diagnostic information about the compile is
  2431. generated</td>
  2432. <td valign="top" align="center">No</td>
  2433. </tr>
  2434. <tr>
  2435. <td valign="top">excludes</td>
  2436. <td valign="top">comma separated list of patterns of files that must be
  2437. excluded. No files (except default excludes) are excluded when
  2438. omitted.</td>
  2439. <td valign="top" align="center">No</td>
  2440. </tr>
  2441. <tr>
  2442. <td valign="top">explicit</td>
  2443. <td valign="top">Whether variables must be declared explicitly
  2444. before use</td>
  2445. <td valign="top" align="center">No</td>
  2446. </tr>
  2447. <tr>
  2448. <td valign="top">format</td>
  2449. <td valign="top">Whether the generated java code is formatted nicely
  2450. or left to match NetRexx line numbers for call stack debugging</td>
  2451. <td valign="top" align="center">No</td>
  2452. </tr>
  2453. <tr>
  2454. <td valign="top">includes</td>
  2455. <td valign="top">comma separated list of patterns of files that must be
  2456. included. All files are included when omitted.</td>
  2457. <td valign="top" align="center">No</td>
  2458. </tr>
  2459. <tr>
  2460. <td valign="top">java</td>
  2461. <td valign="top">Whether the generated java code is produced</td>
  2462. <td valign="top" align="center">No</td>
  2463. </tr>
  2464. <tr>
  2465. <td valign="top">keep</td>
  2466. <td valign="top">Sets whether the generated java source file should be kept
  2467. after compilation. The generated files will have an extension of
  2468. .java.keep, <b>not</b> .java</td>
  2469. <td valign="top" align="center">No</td>
  2470. </tr>
  2471. <tr>
  2472. <td valign="top">logo</td>
  2473. <td valign="top">Whether the compiler text logo is displayed when
  2474. compiling</td>
  2475. <td valign="top" align="center">No</td>
  2476. </tr>
  2477. <tr>
  2478. <td valign="top">replace</td>
  2479. <td valign="top">Whether the generated .java file should be replaced
  2480. when compiling</td>
  2481. <td valign="top" align="center">No</td>
  2482. </tr>
  2483. <tr>
  2484. <td valign="top">savelog</td>
  2485. <td valign="top">Whether the compiler messages will be written to
  2486. NetRexxC.log as well as to the console</td>
  2487. <td valign="top" align="center">No</td>
  2488. </tr>
  2489. <tr>
  2490. <td valign="top">sourcedir</td>
  2491. <td valign="top">Tells the NetRexx compiler to store the class files in the
  2492. same directory as the source files. The alternative is the working
  2493. directory</td>
  2494. <td valign="top" align="center">No</td>
  2495. </tr>
  2496. <tr>
  2497. <td valign="top">srcDir</td>
  2498. <td valign="top">Set the source dir to find the source Netrexx
  2499. files</td>
  2500. <td valign="top" align="center">Yes</td>
  2501. </tr>
  2502. <tr>
  2503. <td valign="top">strictargs</td>
  2504. <td valign="top">Tells the NetRexx compiler that method calls always
  2505. need parentheses, even if no arguments are needed, e.g.
  2506. <code>aStringVar.getBytes</code> vs.
  2507. <code>aStringVar.getBytes()</code></td>
  2508. <td valign="top" align="center">No</td>
  2509. </tr>
  2510. <tr>
  2511. <td valign="top">strictassign</td>
  2512. <td valign="top">Tells the NetRexx compile that assignments must
  2513. match exactly on type</td>
  2514. <td valign="top" align="center">No</td>
  2515. </tr>
  2516. <tr>
  2517. <td valign="top">strictcase</td>
  2518. <td valign="top">Specifies whether the NetRexx compiler should be
  2519. case sensitive or not</td>
  2520. <td valign="top" align="center">No</td>
  2521. </tr>
  2522. <tr>
  2523. <td valign="top">strictimport</td>
  2524. <td valign="top">Whether classes need to be imported explicitly using an
  2525. <code>import</code> statement. By default the NetRexx compiler will
  2526. import certain packages automatically</td>
  2527. <td valign="top" align="center">No</td>
  2528. </tr>
  2529. <tr>
  2530. <td valign="top">strictprops</td>
  2531. <td valign="top">Whether local properties need to be qualified
  2532. explicitly using <code>this</code></td>
  2533. <td valign="top" align="center">No</td>
  2534. </tr>
  2535. <tr>
  2536. <td valign="top">strictsignal</td>
  2537. <td valign="top">Whether the compiler should force catching of
  2538. exceptions by explicitly named types</td>
  2539. <td valign="top" align="center">No</td>
  2540. </tr>
  2541. <tr>
  2542. <td valign="top">symbols</td>
  2543. <td valign="top">Whether debug symbols should be generated into the
  2544. class file</td>
  2545. <td valign="top" align="center">No</td>
  2546. </tr>
  2547. <tr>
  2548. <td valign="top">time</td>
  2549. <td valign="top">Asks the NetRexx compiler to print compilation
  2550. times to the console</td>
  2551. <td valign="top" align="center">No</td>
  2552. </tr>
  2553. <tr>
  2554. <td valign="top">trace</td>
  2555. <td valign="top">Turns on or off tracing and directs the resultant
  2556. trace output</td>
  2557. <td valign="top" align="center">No</td>
  2558. </tr>
  2559. <tr>
  2560. <td valign="top">utf8</td>
  2561. <td valign="top">Tells the NetRexx compiler that the source is in UTF8</td>
  2562. <td valign="top" align="center">No</td>
  2563. </tr>
  2564. <tr>
  2565. <td valign="top">verbose</td>
  2566. <td valign="top">Whether lots of warnings and error messages should
  2567. be generated</td>
  2568. <td valign="top" align="center">Yes</td>
  2569. </tr>
  2570. </table>
  2571. <h3>Examples</h3>
  2572. <blockquote>
  2573. <p><code>&lt;netrexxc srcDir=&quot;/source/project&quot;
  2574. includes=&quot;vnr/util/*&quot;
  2575. destDir=&quot;/source/project/build&quot;
  2576. classpath=&quot;/source/project2/proj.jar&quot;
  2577. comments=&quot;true&quot;
  2578. crossref=&quot;false&quot; replace=&quot;true&quot;
  2579. keep=&quot;true&quot; /&gt;</code>
  2580. </p>
  2581. </blockquote>
  2582. <hr>
  2583. <h2><a name="renameexts">RenameExtensions</a></h2>
  2584. <h3><b>Description:</b></h3>
  2585. <p>Renames files in the <code>srcDir</code> directory ending with the
  2586. <code>fromExtension</code> string so that they end with the
  2587. <code>toExtension</code> string. Files are only replaced if
  2588. <code>replace</code> is true
  2589. </p>
  2590. <p>See the section on
  2591. <a href="#directorybasedtasks">directory based tasks</a>, on how the
  2592. inclusion/exclusion of files works, and how to write patterns. The
  2593. patterns are relative to the <i>srcDir</i> directory.</p>
  2594. <h3>Parameters:</h3>
  2595. <table border="1" cellpadding="2" cellspacing="0">
  2596. <tr>
  2597. <td valign="top"><b>Attribute</b></td>
  2598. <td valign="top"><b>Description</b></td>
  2599. <td align="center" valign="top"><b>Required</b></td>
  2600. </tr>
  2601. <tr>
  2602. <td valign="top">defaultexcludes</td>
  2603. <td valign="top">indicates whether default excludes should be used or not
  2604. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
  2605. omitted.</td>
  2606. <td valign="top" align="center">No</td>
  2607. </tr>
  2608. <tr>
  2609. <td valign="top">excludes</td>
  2610. <td valign="top">comma separated list of patterns of files that must be
  2611. excluded. No files (except default excludes) are excluded when
  2612. omitted.</td>
  2613. <td valign="top" align="center">No</td>
  2614. </tr>
  2615. <tr>
  2616. <td valign="top">fromExtention</td>
  2617. <td valign="top">The string that files must end in to be renamed</td>
  2618. <td valign="top" align="center">Yes</td>
  2619. </tr>
  2620. <tr>
  2621. <td valign="top">includes</td>
  2622. <td valign="top">comma separated list of patterns of files that must be
  2623. included. All files are included when omitted.</td>
  2624. <td valign="top" align="center">No</td>
  2625. </tr>
  2626. <tr>
  2627. <td valign="top">replace</td>
  2628. <td valign="top">Whether the file being renamed to should be
  2629. replaced if it already exists</td>
  2630. <td valign="top" align="center">No</td>
  2631. </tr>
  2632. <tr>
  2633. <td valign="top">srcDir</td>
  2634. <td valign="top">The starting directory for files to search in</td>
  2635. <td valign="top" align="center">Yes</td>
  2636. </tr>
  2637. <tr>
  2638. <td valign="top">toExtension</td>
  2639. <td valign="top">The string that renamed files will end with on
  2640. completion</td>
  2641. <td valign="top" align="center">Yes</td>
  2642. </tr>
  2643. </table>
  2644. <h3>Examples</h3>
  2645. <blockquote>
  2646. <p><code>&lt;renameext srcDir=&quot;/source/project1&quot;
  2647. includes=&quot;**&quot;
  2648. excludes=&quot;**/samples/*&quot;
  2649. fromExtension=&quot;.java.keep&quot;
  2650. toExtension=&quot;.java&quot;
  2651. replace=&quot;true&quot; /&gt;
  2652. </code>
  2653. </p>
  2654. </blockquote>
  2655. <hr>
  2656. <h2><a name="script">Script</a></h2>
  2657. <h3><b>Description:</b></h3>
  2658. <p>Execute a script in a
  2659. <a href="http://www.alphaworks.ibm.com/tech/bsf">BSF</a> supported language.
  2660. <p>All items (tasks, targets, etc) of the running project are accessible
  2661. from the script.
  2662. <h3>Parameters:</h3>
  2663. <table border="1" cellpadding="2" cellspacing="0">
  2664. <tr>
  2665. <td valign="top"><b>Attribute</b></td>
  2666. <td valign="top"><b>Description</b></td>
  2667. <td align="center" valign="top"><b>Required</b></td>
  2668. </tr>
  2669. <tr>
  2670. <td valign="top">language</td>
  2671. <td valign="top">The programming language the script is written in.
  2672. Must be a supported BSF language</td>
  2673. <td valign="top" align="center">No</td>
  2674. </tr>
  2675. <tr>
  2676. <td valign="top">src</td>
  2677. <td valign="top">The location of the script as a file, if not inline</td>
  2678. <td valign="top" align="center">No</td>
  2679. </tr>
  2680. </table>
  2681. <h3>Examples</h3>
  2682. <blockquote>
  2683. <p>None yet available</p>
  2684. </blockquote>
  2685. </body>
  2686. </html>