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 112 kB

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