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

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