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

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

Introduction

No Description

No topics