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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
  5. <meta name="ProgId" content="FrontPage.Editor.Document">
  6. <title>Ant</title>
  7. </head>
  8. <body>
  9. <h1>Ant User Manual</h1>
  10. <p>by&nbsp;</p>
  11. <ul>
  12. <li>James Duncan Davison <a href="mailto:(duncan@x180.com">(duncan@x180.com</a>)</li>
  13. <li>Arnout J. Kuiper <a href="mailto:(ajkuiper@wxs.nl">(ajkuiper@wxs.nl</a>)</li>
  14. <li>Stefano Mazzocchi <a href="mailto:(stefano@apache.org">(stefano@apache.org</a>)</li>
  15. </ul>
  16. <p>Version 1.0.2 - 2000/01/26</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="#tasks">Built in Tasks</a>
  27. <li><a href="#writingowntask">Writing your own task</a></li>
  28. <li><a href="#license">License</a></li>
  29. <li><a href="#feedback">Feedback</a></li>
  30. </ul>
  31. <hr>
  32. <h2><a name="introduction">Introduction</a></h2>
  33. <p>Ant is a Java based build tool. In theory it is kind of like make without
  34. makes wrinkles.</p>
  35. <h3>Why?</h3>
  36. <p>Why another build tool when there is already make, gnumake, nmake, jam, and
  37. others? Because all of those tools have limitations that its original author
  38. couldn't live with when developing software across multiple platforms. Make like
  39. tools are inherently shell based. They evaluate a set of dependencies and then
  40. execute commands not unlike what you would issue on a shell. This means that you
  41. can easily extend these tools by using or writing any program for the OS that
  42. you are working on. However, this also means that you limit yourself to the OS,
  43. or at least the OS type such as Unix, that you are working on.</p>
  44. <p>Makefiles are inherently evil as well. Anybody who has worked on them for any
  45. time has run into the dreaded tab problem. &quot;Is my command not executing
  46. because I have a space in front of my tab!!!&quot; said the original author of
  47. Ant way too many times. Tools like Jam took care of this to a great degree, but
  48. still use yet another format to use and remember.</p>
  49. <p>Ant is different. Instead a model where it is extended with shell based
  50. commands, it is extended using Java classes. Instead of writing shell commands,
  51. the configuration files are XML based calling out a target tree where various
  52. tasks get executed. Each task is run by an object which implements a particular
  53. Task interface.</p>
  54. <p>Granted, this removes some of the expressive power that is inherent by being
  55. able to construct a shell command such as `find . -name foo -exec rm {}` but it
  56. gives you the ability to be cross platform. To work anywhere and everywhere. And
  57. hey, if you really need to execute a shell command, Ant has an exec rule that
  58. allows different commands to be executed based on the OS that it is executing
  59. on.</p>
  60. <hr>
  61. <h2><a name="getting">Getting Ant</a></h2>
  62. <h3>Binary edition</h3>
  63. <p>The latest stable version of Ant can be downloaded from <a
  64. href="http://jakarta.apache.org/builds/tomcat/release/v3.0/ant.zip">http://jakarta.apache.org/builds/tomcat/release/v3.0/ant.zip</a>.
  65. If you like living on the edge, you can download the latest version from <a
  66. href="http://jakarta.apache.org/builds/tomcat/nightly/ant.zip">http://jakarta.apache.org/builds/tomcat/nightly/ant.zip</a>.</p>
  67. <h3>Source edition</h3>
  68. <p>If you prefer the source edition, you can download Ant from <a
  69. 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>
  70. (latest stable) or from <a
  71. href="http://jakarta.apache.org/from-cvs/jakarta-tools/">http://jakarta.apache.org/from-cvs/jakarta-ant/</a>
  72. (current). See the section <a href="#buildingant">Building Ant</a> on how to
  73. build Ant from the source code.</p>
  74. <hr>
  75. <h2><a name="buildingant">Building Ant</a></h2>
  76. <p>Go to the directory <code>jakarta-ant</code>.</p>
  77. <p>Make sure the JDK is in you path.</p>
  78. <p>Run <code>bootstrap.bat</code> (Windows) or <code>bootstrap.sh</code> (UNIX)
  79. to build a bootstrap version of Ant.</p>
  80. <p>When finished, use</p>
  81. <blockquote>
  82. <p><code>build.bat -Ddist.dir=&lt;directory to install Ant&gt; dist</code></p>
  83. </blockquote>
  84. <p>for Windows, and</p>
  85. <blockquote>
  86. <p><code>build.sh -Ddist.dir=&lt;directory to install Ant&gt; dist</code></p>
  87. </blockquote>
  88. <p>for UNIX, to create a binary distribution of Ant. This distribution can be
  89. found in the directory you specified.</p>
  90. <hr>
  91. <h2><a name="installing">Installing Ant</a></h2>
  92. <p>The binary distribution of Ant consists of three directories: <code>bin</code>,
  93. <code>docs</code> and <code>lib</code>. Only the <code>bin</code> and <code>lib</code>
  94. directory are crucial for running Ant. To run Ant, the following must be done:</p>
  95. <ul>
  96. <li>Add the <code>bin</code> directory to your path.</li>
  97. <li>Set the ANT_HOME environment variable. This should be set to the directory
  98. which contains the <code>bin</code> and <code>lib</code> directory.</li>
  99. <li>Set the JAVA_HOME environment variable. This should be set to the
  100. directory where the JDK is installed.</li>
  101. </ul>
  102. <h3>Windows</h3>
  103. <p>Assume Ant is installed in <code>c:\ant\</code>. The following sets up the
  104. environment:</p>
  105. <pre>set ANT_HOME=c:\ant
  106. set JAVA_HOME=c:\jdk1.2.2
  107. set PATH=%PATH%;%ANT_HOME%\bin</pre>
  108. <h3>Unix (bash)</h3>
  109. <p>Assume Ant is installed in <code>/usr/local/ant</code>. The following sets up
  110. the environment:</p>
  111. <pre>export ANT_HOME=/usr/local/ant
  112. export JAVA_HOME=/usr/local/jdk-1.2.2
  113. export PATH=${PATH}:${ANT_HOME}/bin</pre>
  114. <h3>Advanced</h3>
  115. <p>There are lots of variants that can be used to run Ant. What you need is at
  116. least the following:</p>
  117. <p>The classpath for Ant must contain <code>ant.jar</code> and <code>xml.jar</code>.</p>
  118. <p>When you need JDK functionality (like a <a href="#javac">javac</a> task, or a
  119. <a href="#rmic">rmic</a> task), then for JDK 1.1, the <code>classes.zip</code>
  120. file of the JDK must be added to the classpath; for JDK 1.2, <code>tools.jar</code>
  121. must be added.</p>
  122. <p>When you are executing platform specific applications (like the <a
  123. href="#exec">exec</a> task, or the <a href="#cvs">cvs</a> task), the property <code>ant.home</code>
  124. must be set to the directory containing a bin directory, which contains <code>antRun.bat</code>
  125. (Windows) or <code>antRun</code> (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. <pre>&lt;target name=&quot;A&quot;/&gt;
  228. &lt;target name=&quot;B&quot; depends=&quot;A&quot;/&gt;
  229. &lt;target name=&quot;C&quot; depends=&quot;B&quot;/&gt;
  230. &lt;target name=&quot;D&quot; depends=&quot;C,B,A&quot;/&gt;</pre>
  231. <p>Suppose we want to execute target D. From its <i>depends</i> attribute, you
  232. might think that first target C, then B and then A is executed. Wrong! C depends
  233. on B, and B depends on A, so first A is executed, then B, then C, and finally D.</p>
  234. <p>In situations without such dependencies, you can rely on the order of the
  235. targets in the <i>depends</i> attributes.</p>
  236. <p>A target gets executed only once. Even when more targets depend on it (see
  237. the previous example).</p>
  238. <p>A target has the following attributes:</p>
  239. <table border="1" cellpadding="2" cellspacing="0">
  240. <tr>
  241. <td valign="top"><b>Attribute</b></td>
  242. <td valign="top"><b>Description</b></td>
  243. <td align="center" valign="top"><b>Required</b></td>
  244. </tr>
  245. <tr>
  246. <td valign="top">name</td>
  247. <td valign="top">the name of the project.</td>
  248. <td align="center" valign="top">Yes</td>
  249. </tr>
  250. <tr>
  251. <td valign="top">depends</td>
  252. <td valign="top">a comma separated list of names of targets on which this
  253. target depends.</td>
  254. <td align="center" valign="top">No</td>
  255. </tr>
  256. </table>
  257. <h3>Tasks</h3>
  258. <p>A task is a piece of code that can be executed.</p>
  259. <p>A task can have multiple attributes (or arguments if you prefer). The value
  260. of an attribute might contain references to a property. These references will be
  261. resolved before the task is executed.</p>
  262. <p>Tasks have a common structure:</p>
  263. <blockquote>
  264. <pre>&lt;name attribute1=&quot;value1&quot; attribute2=&quot;value2&quot; ... /&gt;</pre>
  265. </blockquote>
  266. <p>where name is the name of the task, attribute-x the attribute name, and
  267. value-x the value of this attribute.</p>
  268. <p>There is a set of <a href="#tasks">built in tasks</a>, but it is also very
  269. easy to <a href="#writingowntask">write your own</a>.</p>
  270. <h3>Properties</h3>
  271. <p>A project can have a set of properties. These might be set in the buildfile
  272. by the <a href="#property">property task</a>, or might be set outside Ant. A
  273. property has a name and a value. Properties might be used in in the value of
  274. task attributes. This is done by placing the property name between
  275. &quot;${&quot; and &quot;}&quot; in the attribute value.</p>
  276. <p>If there is a property called &quot;builddir&quot; with the value
  277. &quot;build&quot;, then this could be used in an attribute like this: &quot;${builddir}/classes&quot;.
  278. This is resolved as &quot;build/classes&quot;.</p>
  279. <h3>Examples</h3>
  280. <blockquote>
  281. <pre>&lt;project name=&quot;foo&quot; default=&quot;dist&quot; basedir=&quot;.&quot;&gt;
  282. &lt;target name=&quot;init&quot;&gt;
  283. &lt;tstamp/&gt;
  284. &lt;property name=&quot;build&quot; value=&quot;build&quot; /&gt;
  285. &lt;property name=&quot;dist&quot; value=&quot;dist&quot; /&gt;
  286. &lt;/target&gt;
  287. &lt;target name=&quot;prepare&quot; depends=&quot;init&quot;&gt;
  288. &lt;mkdir dir=&quot;${build}&quot; /&gt;
  289. &lt;/target&gt;
  290. &lt;target name=&quot;compile&quot; depends=&quot;prepare&quot;&gt;
  291. &lt;javac srcdir=&quot;${src}&quot; destdir=&quot;${build}&quot; /&gt;
  292. &lt;/target&gt;
  293. &lt;target name=&quot;dist&quot; depends=&quot;compile&quot;&gt;
  294. &lt;mkdir dir=&quot;${dist}/lib&quot; /&gt;
  295. &lt;jar jarfile=&quot;${dist}/lib/foo${DSTAMP}.jar&quot;
  296. basedir=&quot;${build}&quot; items=&quot;com&quot;/&gt;
  297. &lt;/target&gt;
  298. &lt;target name=&quot;clean&quot; depends=&quot;init&quot;&gt;
  299. &lt;deltree dir=&quot;${build}&quot; /&gt;
  300. &lt;deltree dir=&quot;${dist}&quot; /&gt;
  301. &lt;/target&gt;
  302. &lt;/project&gt;
  303. </pre>
  304. </blockquote>
  305. <hr>
  306. <h2><a name="tasks">Built in tasks</a></h2>
  307. <ul>
  308. <li><a href="#ant">Ant</a></li>
  309. <li><a href="#chmod">Chmod</a></li>
  310. <li><a href="#copydir">Copydir</a></li>
  311. <li><a href="#copyfile">Copyfile</a></li>
  312. <li><a href="#cvs">Cvs</a></li>
  313. <li><a href="#delete">Delete</a></li>
  314. <li><a href="#deltree">Deltree</a></li>
  315. <li><a href="#echo">Echo</a></li>
  316. <li><a href="#exec">Exec</a></li>
  317. <li><a href="#expand">Expand</a></li>
  318. <li><a href="#get">Get</a></li>
  319. <li><a href="#gzip">GZip</a></li>
  320. <li><a href="#jar">Jar</a></li>
  321. <li><a href="#java">Java</a></li>
  322. <li><a href="#javac">Javac</a></li>
  323. <li><a href="#javadoc">Javadoc/Javadoc2</a></li>
  324. <li><a href="#keysubst">KeySubst</a></li>
  325. <li><a href="#mkdir">Mkdir</a></li>
  326. <li><a href="#property">Property</a></li>
  327. <li><a href="#replace">Replace</a></li>
  328. <li><a href="#rmic">Rmic</a></li>
  329. <li><a href="#taskdef">Taskdef</a></li>
  330. <li><a href="#tstamp">Tstamp</a></li>
  331. <li><a href="#zip">Zip</a></li>
  332. </ul>
  333. <hr>
  334. <h2><a name="ant">Ant</a></h2>
  335. <h3><b>Description:</b></h3>
  336. <p>Runs Ant on a supplied buildfile. This can be used to build subprojects.</p>
  337. <p>When the <i>antfile</i> attribute is omitted, the file &quot;build.xml&quot;
  338. in the supplied directory (<i>dir</i> attribute) is used.</p>
  339. <p>If no target attribute is supplied, the default target of the new project is
  340. used.</p>
  341. <p>The properties of the current project will be available in the new project.
  342. These properties will override the properties that are set in the new project.
  343. (See also the <a href="#property">properties task</a>).</p>
  344. <h3>Parameters:</h3>
  345. <table border="1" cellpadding="2" cellspacing="0">
  346. <tr>
  347. <td valign="top"><b>Attribute</b></td>
  348. <td valign="top"><b>Description</b></td>
  349. <td align="center" valign="top"><b>Required</b></td>
  350. </tr>
  351. <tr>
  352. <td valign="top">antfile</td>
  353. <td valign="top">the buildfile to use.</td>
  354. <td valign="top" align="center">No</td>
  355. </tr>
  356. <tr>
  357. <td valign="top">dir</td>
  358. <td valign="top">the directory to use as a basedir for the new Ant project.</td>
  359. <td valign="top" align="center">Yes</td>
  360. </tr>
  361. <tr>
  362. <td valign="top">target</td>
  363. <td valign="top">the target of the new Ant project that should be executed.</td>
  364. <td valign="top" align="center">No</td>
  365. </tr>
  366. </table>
  367. <h3>Examples</h3>
  368. <blockquote>
  369. <p><code>&lt;ant antfile=&quot;subproject/subbuild.xml&quot; dir=&quot;subproject&quot;
  370. target=&quot;compile&quot; /&gt;</code></p>
  371. <p><code>&lt;ant dir=&quot;subproject&quot; /&gt;</code></p>
  372. </blockquote>
  373. <hr>
  374. <h2><a name="chmod">Chmod</a></h2>
  375. <h3>Description</h3>
  376. <p>Changes the permissions of a file. Right now it has efect only under Unix.
  377. The permissions are also UNIX style, like the argument for the chmod command.</p>
  378. <h3>Parameters</h3>
  379. <table border="1" cellpadding="2" cellspacing="0">
  380. <tr>
  381. <td valign="top"><b>Attribute</b></td>
  382. <td valign="top"><b>Description</b></td>
  383. <td align="center" valign="top"><b>Required</b></td>
  384. </tr>
  385. <tr>
  386. <td valign="top">src</td>
  387. <td valign="top">the file of which the permissions must be changed.</td>
  388. <td valign="top" align="center">Yes</td>
  389. </tr>
  390. <tr>
  391. <td valign="top">perm</td>
  392. <td valign="top">the new permissions.</td>
  393. <td valign="top" align="center">Yes</td>
  394. </tr>
  395. </table>
  396. <h3>Examples</h3>
  397. <blockquote>
  398. <p><code>&lt;chmod src=&quot;${dist}/start.sh&quot; perm=&quot;ugo+rx&quot;
  399. /&gt;</code></p>
  400. </blockquote>
  401. <p>makes the &quot;start.sh&quot; file readable and executable for anyone on a
  402. UNIX system.</p>
  403. <hr>
  404. <h2><a name="copydir">Copydir</a></h2>
  405. <h3>Description</h3>
  406. <p>Copies a directory tree from the source to the destination.</p>
  407. <p>It is possible to exclude a set of files from the files that are being
  408. copied. This can be done with the <i>ignore</i> attribute. This attribute
  409. contains the names of the files/directories that must be excluded from the copy.
  410. The names specified in the <i>ignore</i> attribute are just names, they do not
  411. contain any path information!</p>
  412. <h3>Parameters</h3>
  413. <table border="1" cellpadding="2" cellspacing="0">
  414. <tr>
  415. <td valign="top"><b>Attribute</b></td>
  416. <td valign="top"><b>Description</b></td>
  417. <td align="center" valign="top"><b>Required</b></td>
  418. </tr>
  419. <tr>
  420. <td valign="top">src</td>
  421. <td valign="top">the directory to copy.</td>
  422. <td valign="top" align="center">Yes</td>
  423. </tr>
  424. <tr>
  425. <td valign="top">dest</td>
  426. <td valign="top">the directory to copy to.</td>
  427. <td valign="top" align="center">Yes</td>
  428. </tr>
  429. <tr>
  430. <td valign="top">ignore</td>
  431. <td valign="top">comma separated list of filenames/directorynames to ignore.</td>
  432. <td valign="top" align="center">No</td>
  433. </tr>
  434. </table>
  435. <h3>Examples</h3>
  436. <blockquote>
  437. <p><code>&lt;copydir src=&quot;${src}/resources&quot; dest=&quot;${dist}&quot;
  438. /&gt;</code></p>
  439. </blockquote>
  440. <p>copies the directory <code>${src}/resources</code> to <code>${dist}</code>.</p>
  441. <blockquote>
  442. <p><code>&lt;copydir src=&quot;${src}/resources&quot; dest=&quot;${dist}&quot;
  443. ignore=&quot;old, Test.java&quot; /&gt;</code></p>
  444. </blockquote>
  445. <p>copies the directory <code>${src}/resources</code> to <code>${dist}</code>.
  446. All files/directories with the names <code>old</code> and <code>Test.java</code>
  447. are excluded from the copy. When <code>old</code> or <code>Test.java</code> is
  448. the name of a directory, then that whole directory is excluded from the copy.</p>
  449. <hr>
  450. <h2><a name="copyfile">Copyfile</a></h2>
  451. <h3>Description</h3>
  452. <p>Copies a file from the source to the destination. The file is only copied if
  453. the source file is newer than the destination file, or when the destination file
  454. does not exist.</p>
  455. <h3>Parameters</h3>
  456. <table border="1" cellpadding="2" cellspacing="0">
  457. <tr>
  458. <td valign="top"><b>Attribute</b></td>
  459. <td valign="top"><b>Description</b></td>
  460. <td align="center" valign="top"><b>Required</b></td>
  461. </tr>
  462. <tr>
  463. <td valign="top">src</td>
  464. <td valign="top">the filename of the file to copy.</td>
  465. <td valign="top" align="center">Yes</td>
  466. </tr>
  467. <tr>
  468. <td valign="top">dest</td>
  469. <td valign="top">the filename of the file where to copy to.</td>
  470. <td valign="top" align="center">Yes</td>
  471. </tr>
  472. </table>
  473. <h3>Examples</h3>
  474. <blockquote>
  475. <p><code>&lt;copyfile src=&quot;test.java&quot; dest=&quot;subdir/test.java&quot;
  476. /&gt;</code></p>
  477. <p><code>&lt;copyfile src=&quot;${src}/index.html&quot; dest=&quot;${dist}/help/index.html&quot;
  478. /&gt;</code></p>
  479. </blockquote>
  480. <hr>
  481. <h2><a name="cvs">Cvs</a></h2>
  482. <h3>Description</h3>
  483. <p>Checks out a package/module from a <a href="http://www.cyclic.com/">CVS</a>
  484. repository.</p>
  485. <p>When doing automated builds, the <a href="#get">get task</a> should be
  486. preferred, because of speed.</p>
  487. <h3>Parameters</h3>
  488. <table border="1" cellpadding="2" cellspacing="0">
  489. <tr>
  490. <td valign="top"><b>Attribute</b></td>
  491. <td valign="top"><b>Description</b></td>
  492. <td align="center" valign="top"><b>Required</b></td>
  493. </tr>
  494. <tr>
  495. <td valign="top">cvsRoot</td>
  496. <td valign="top">the CVSROOT variable.</td>
  497. <td align="center" valign="top">Yes</td>
  498. </tr>
  499. <tr>
  500. <td valign="top">dest</td>
  501. <td valign="top">the directory where the checked out files should be placed.</td>
  502. <td align="center" valign="top">Yes</td>
  503. </tr>
  504. <tr>
  505. <td valign="top">package</td>
  506. <td valign="top">the package/module to check out.</td>
  507. <td align="center" valign="top">Yes</td>
  508. </tr>
  509. <tr>
  510. <td valign="top">tag</td>
  511. <td valign="top">the tag of the package/module to check out.</td>
  512. <td align="center" valign="top">No</td>
  513. </tr>
  514. </table>
  515. <h3>Examples</h3>
  516. <blockquote>
  517. <p><code>&lt;cvs cvsRoot=&quot;:pserver:anoncvs@jakarta.apache.org:/home/cvspublic&quot;
  518. package=&quot;jakarta-tools&quot; dest=&quot;${ws.dir}&quot; /&gt;</code></p>
  519. </blockquote>
  520. <p>This checks out the package/module &quot;jakarta-tools&quot; from the CVS
  521. repository pointed to by the cvsRoot attribute, and stores the files in &quot;${ws.dir}&quot;.</p>
  522. <hr>
  523. <h2><a name="delete">Delete</a></h2>
  524. <h3>Description</h3>
  525. <p>Deletes a single file.</p>
  526. <h3>Parameters</h3>
  527. <table border="1" cellpadding="2" cellspacing="0">
  528. <tr>
  529. <td valign="top"><b>Attribute</b></td>
  530. <td valign="top"><b>Description</b></td>
  531. <td align="center" valign="top"><b>Required</b></td>
  532. </tr>
  533. <tr>
  534. <td valign="top">file</td>
  535. <td valign="top">the file to delete.</td>
  536. <td valign="top" align="center">Yes</td>
  537. </tr>
  538. </table>
  539. <h3>Examples</h3>
  540. <blockquote>
  541. <p><code>&lt;delete file=&quot;/lib/ant.jar&quot; /&gt;</code></p>
  542. <p><code>&lt;delete file=&quot;${ant}&quot; /&gt;</code></p>
  543. </blockquote>
  544. <hr>
  545. <h2><a name="deltree">Deltree</a></h2>
  546. <h3>Description</h3>
  547. <p>Deletes a directory with all its files and subdirectories.</p>
  548. <h3>Parameters</h3>
  549. <table border="1" cellpadding="2" cellspacing="0">
  550. <tr>
  551. <td valign="top"><b>Attribute</b></td>
  552. <td valign="top"><b>Description</b></td>
  553. <td align="center" valign="top"><b>Required</b></td>
  554. </tr>
  555. <tr>
  556. <td valign="top">dir</td>
  557. <td valign="top">the directory to delete.</td>
  558. <td valign="top" align="center">Yes</td>
  559. </tr>
  560. </table>
  561. <h3>Examples</h3>
  562. <blockquote>
  563. <p><code>&lt;deltree dir=&quot;dist&quot; /&gt;</code></p>
  564. <p><code>&lt;deltree dir=&quot;${dist}&quot; /&gt;</code></p>
  565. </blockquote>
  566. <hr>
  567. <h2><a name="echo">Echo</a></h2>
  568. <h3>Description</h3>
  569. <p>Echoes a message to System.out.</p>
  570. <h3>Parameters</h3>
  571. <table border="1" cellpadding="2" cellspacing="0">
  572. <tr>
  573. <td valign="top"><b>Attribute</b></td>
  574. <td valign="top"><b>Description</b></td>
  575. <td align="center" valign="top"><b>Required</b></td>
  576. </tr>
  577. <tr>
  578. <td valign="top">message</td>
  579. <td valign="top">the message to echo.</td>
  580. <td valign="top" align="center">Yes</td>
  581. </tr>
  582. </table>
  583. <h3>Examples</h3>
  584. <blockquote>
  585. <p><code>&lt;echo message=&quot;Hello world&quot; /&gt;</code></p>
  586. </blockquote>
  587. <hr>
  588. <h2><a name="exec">Exec</a></h2>
  589. <h3>Description</h3>
  590. <p>Executes a system command. When the <i>os</i> attribute is specified, then
  591. the command is only executed when Ant is run on one of the specified operating
  592. systems.</p>
  593. <h3>Parameters</h3>
  594. <table border="1" cellpadding="2" cellspacing="0">
  595. <tr>
  596. <td valign="top"><b>Attribute</b></td>
  597. <td valign="top"><b>Description</b></td>
  598. <td align="center" valign="top"><b>Required</b></td>
  599. </tr>
  600. <tr>
  601. <td valign="top">command</td>
  602. <td valign="top">the command to execute.</td>
  603. <td align="center" valign="top">Yes</td>
  604. </tr>
  605. <tr>
  606. <td valign="top">dir</td>
  607. <td valign="top">the directory in which the command should be executed.</td>
  608. <td align="center" valign="top">Yes</td>
  609. </tr>
  610. <tr>
  611. <td valign="top">os</td>
  612. <td valign="top">list of Operating Systems on which the command may be
  613. executed.</td>
  614. <td align="center" valign="top">No</td>
  615. </tr>
  616. <tr>
  617. <td valign="top">output</td>
  618. <td valign="top">the file to which the output of the command should be
  619. redirected.</td>
  620. <td align="center" valign="top">Yes</td>
  621. </tr>
  622. </table>
  623. <h3>Examples</h3>
  624. <blockquote>
  625. <p><code>&lt;exec dir=&quot;${src}&quot; command=&quot;dir&quot; os=&quot;windows&quot;
  626. output=&quot;dir.txt&quot; /&gt;</code></p>
  627. </blockquote>
  628. <hr>
  629. <h2><a name="expand">Expand</a></h2>
  630. <h3>Description</h3>
  631. <p>Unzips a zipfile.</p>
  632. <h3>Parameters</h3>
  633. <table border="1" cellpadding="2" cellspacing="0">
  634. <tr>
  635. <td valign="top"><b>Attribute</b></td>
  636. <td valign="top"><b>Description</b></td>
  637. <td align="center" valign="top"><b>Required</b></td>
  638. </tr>
  639. <tr>
  640. <td valign="top">src</td>
  641. <td valign="top">zipfile to expand.</td>
  642. <td align="center" valign="top">Yes</td>
  643. </tr>
  644. <tr>
  645. <td valign="top">dest</td>
  646. <td valign="top">directory where to store the expanded files.</td>
  647. <td align="center" valign="top">Yes</td>
  648. </tr>
  649. </table>
  650. <h3>Examples</h3>
  651. <blockquote>
  652. <p><code>&lt;expand src=&quot;${tomcat_src}/tools-src.zip&quot; dest=&quot;${tools.home}&quot;
  653. /&gt;</code></p>
  654. </blockquote>
  655. <hr>
  656. <h2><a name="get">Get</a></h2>
  657. <h3>Description</h3>
  658. <p>Gets a file from an URL. When the verbose option is &quot;on&quot;, this task
  659. displays a '.' for every 100 Kb retrieved.</p>
  660. <p>This task should be preferred above the <a href="#cvs">CVS task</a> when
  661. doing automated builds. CVS is significant slower than loading a compressed
  662. archive with http/ftp.</p>
  663. <h3>Parameters</h3>
  664. <table border="1" cellpadding="2" cellspacing="0">
  665. <tr>
  666. <td valign="top"><b>Attribute</b></td>
  667. <td valign="top"><b>Description</b></td>
  668. <td align="center" valign="top"><b>Required</b></td>
  669. </tr>
  670. <tr>
  671. <td valign="top">src</td>
  672. <td valign="top">the URL from which to retrieve a file.</td>
  673. <td align="center" valign="top">Yes</td>
  674. </tr>
  675. <tr>
  676. <td valign="top">dest</td>
  677. <td valign="top">the file where to store the retrieved file.</td>
  678. <td align="center" valign="top">Yes</td>
  679. </tr>
  680. <tr>
  681. <td valign="top">verbose</td>
  682. <td valign="top">show verbose information (&quot;on&quot;/&quot;off&quot;).</td>
  683. <td align="center" valign="top">No</td>
  684. </tr>
  685. </table>
  686. <h3>Examples</h3>
  687. <blockquote>
  688. <p><code>&lt;get src=&quot;http://jakarta.apache.org/&quot; dest=&quot;help/index.html&quot;
  689. /&gt;</code></p>
  690. </blockquote>
  691. <hr>
  692. <h2><a name="gzip">GZip</a></h2>
  693. <h3>Description</h3>
  694. <p>GZips a file.</p>
  695. <h3>Parameters</h3>
  696. <table border="1" cellpadding="2" cellspacing="0">
  697. <tr>
  698. <td valign="top"><b>Attribute</b></td>
  699. <td valign="top"><b>Description</b></td>
  700. <td align="center" valign="top"><b>Required</b></td>
  701. </tr>
  702. <tr>
  703. <td valign="top">src</td>
  704. <td valign="top">the file to gzip.</td>
  705. <td align="center" valign="top">Yes</td>
  706. </tr>
  707. <tr>
  708. <td valign="top">zipfile</td>
  709. <td valign="top">the destination file.</td>
  710. <td align="center" valign="top">Yes</td>
  711. </tr>
  712. </table>
  713. <h3>Examples</h3>
  714. <blockquote>
  715. <p><code>&lt;gzip src=&quot;test.tar&quot; zipfile=&quot;test.tar.gz&quot; /&gt;</code></p>
  716. </blockquote>
  717. <hr>
  718. <h2><a name="jar">Jar</a></h2>
  719. <h3>Description</h3>
  720. <p>Jars a set of files.</p>
  721. <p>The <i>basedir</i> attribute is the reference directory from where to jar.</p>
  722. <p>When &quot;*&quot; is used for items, all files in the basedir, and its
  723. subdirectories, will be jarred. Otherwise all the files and directories
  724. mentioned in the items list will jarred. When a directory is specified, then all
  725. files within it are also jarred.</p>
  726. <p>With the <i>ignore</i> attribute, you can specify files or directories to
  727. ignore. These files will not be jarred. The items in the <i>ignore</i> attribute
  728. override the items in the <i>items</i> attribute. The names specified in the <i>ignore</i>
  729. attribute are just names, they do not contain any path information!</p>
  730. <h3>Parameters</h3>
  731. <table border="1" cellpadding="2" cellspacing="0">
  732. <tr>
  733. <td valign="top"><b>Attribute</b></td>
  734. <td valign="top"><b>Description</b></td>
  735. <td align="center" valign="top"><b>Required</b></td>
  736. </tr>
  737. <tr>
  738. <td valign="top">jarfile</td>
  739. <td valign="top">the jar-file to create.</td>
  740. <td valign="top" align="center">Yes</td>
  741. </tr>
  742. <tr>
  743. <td valign="top">basedir</td>
  744. <td valign="top">the directory from which to jar the files.</td>
  745. <td valign="top" align="center">Yes</td>
  746. </tr>
  747. <tr>
  748. <td valign="top">items</td>
  749. <td valign="top">a comma separated list of the files/directories to jar.</td>
  750. <td valign="top" align="center">Yes</td>
  751. </tr>
  752. <tr>
  753. <td valign="top">ignore</td>
  754. <td valign="top">a comma separated list of the filenames/directorynames to
  755. exclude from the jar.</td>
  756. <td valign="top" align="center">No</td>
  757. </tr>
  758. <tr>
  759. <td valign="top">manifest</td>
  760. <td valign="top">the manifest file to use.</td>
  761. <td valign="top" align="center">No</td>
  762. </tr>
  763. </table>
  764. <h3>Examples</h3>
  765. <blockquote>
  766. <p><code>&lt;jar jarfile=&quot;${dist}/lib/app.jar&quot; basedir=&quot;${build}/classes&quot;
  767. items=&quot;*&quot; /&gt;</code></p>
  768. </blockquote>
  769. <p>jars all files in the <code>${build}/classes</code> directory in a file
  770. called <code>app.jar</code> in the <code>${dist}/lib</code> directory.</p>
  771. <blockquote>
  772. <p><code>&lt;jar jarfile=&quot;${dist}/lib/app.jar&quot; basedir=&quot;${build}/classes&quot;
  773. items=&quot;*&quot; ignore=&quot;Test.class&quot; /&gt;</code></p>
  774. </blockquote>
  775. <p>jars all files in the <code>${build}/classes</code> directory in a file
  776. called <code>app.jar</code> in the <code>${dist}/lib</code> directory.
  777. Files/directories with the name <code>Test.class</code> are excluded.</p>
  778. <hr>
  779. <h2><a name="java">Java</a></h2>
  780. <h3>Description</h3>
  781. <p>Executes a Java class within the running (Ant) VM or forks another VM if
  782. specified.</p>
  783. <p>Be careful that the executed class doesn't call System.exit(), because it
  784. will terminate the VM and thus Ant. In case this happens, it's highly suggested
  785. that you set the fork attribute so that System.exit() stops the other VM and not
  786. the one that is currently running Ant.</p>
  787. <h3>Parameters</h3>
  788. <table border="1" cellpadding="2" cellspacing="0">
  789. <tr>
  790. <td valign="top"><b>Attribute</b></td>
  791. <td valign="top"><b>Description</b></td>
  792. <td align="center" valign="top"><b>Required</b></td>
  793. </tr>
  794. <tr>
  795. <td valign="top">class</td>
  796. <td valign="top">the Java class to execute.</td>
  797. <td align="center" valign="top">Yes</td>
  798. </tr>
  799. <tr>
  800. <td valign="top">args</td>
  801. <td valign="top">the arguments for the class that is executed.</td>
  802. <td align="center" valign="top">No</td>
  803. </tr>
  804. <tr>
  805. <td valign="top">fork</td>
  806. <td valign="top">if enabled triggers the class execution in another VM
  807. (disabled by default)</td>
  808. <td align="center" valign="top">No</td>
  809. </tr>
  810. <tr>
  811. <td valign="top">jvmargs</td>
  812. <td valign="top">the arguments to pass to the forked VM (ignored if fork is
  813. disabled)</td>
  814. <td align="center" valign="top">No</td>
  815. </tr>
  816. </table>
  817. <h3>Examples</h3>
  818. <blockquote>
  819. <p><code>&lt;java class=&quot;test.Main&quot; /&gt;</code></p>
  820. <p><code>&lt;java class=&quot;test.Main&quot; args=&quot;-h&quot; /&gt;</code></p>
  821. <p><code>&lt;java class=&quot;test.Main&quot; args=&quot;-h&quot;
  822. fork=&quot;yes&quot; jvmargs=&quot;-Xrunhprof:cpu=samples,file=log.txt,depth=3&quot;
  823. /&gt;</code></p>
  824. </blockquote>
  825. <hr>
  826. <h2><a name="javac">Javac</a></h2>
  827. <h3>Description</h3>
  828. <p>Compiles a source tree within the running (Ant) VM.</p>
  829. <p>The source and destination directory will be recursively scanned for Java
  830. source files to compile. Only Java files that have no corresponding class file
  831. or where the class file is older than the java file will be compiled.</p>
  832. <p>Files in the source tree, that are no java files, are copied to the
  833. destination directory, allowing support files to be located properly in the
  834. classpath.</p>
  835. <p>The directory structure of the source tree should follow the package
  836. hierarchy.</p>
  837. <p>It is possible to use different compilers. This can be selected with the
  838. &quot;build.compiler&quot; property. There are three choices:</p>
  839. <ul>
  840. <li>classic (the standard compiler of JDK 1.1/1.2)</li>
  841. <li>modern (the new compiler of JDK 1.3)</li>
  842. <li>jikes (the <a
  843. href="http://oss.software.ibm.com/developerworks/opensource/jikes/project">Jikes</a>
  844. compiler)</li>
  845. </ul>
  846. <p>For JDK 1.1/1.2 is classic the default. For JDK 1.3 is modern the default.</p>
  847. <h3>Parameters</h3>
  848. <table border="1" cellpadding="2" cellspacing="0">
  849. <tr>
  850. <td valign="top"><b>Attribute</b></td>
  851. <td valign="top"><b>Description</b></td>
  852. <td align="center" valign="top"><b>Required</b></td>
  853. </tr>
  854. <tr>
  855. <td valign="top">srcdir</td>
  856. <td valign="top">location of the java files.</td>
  857. <td align="center" valign="top">Yes</td>
  858. </tr>
  859. <tr>
  860. <td valign="top">destdir</td>
  861. <td valign="top">location where to store the class files.</td>
  862. <td align="center" valign="top">Yes</td>
  863. </tr>
  864. <tr>
  865. <td valign="top">classpath</td>
  866. <td valign="top">the classpath to use.</td>
  867. <td align="center" valign="top">No</td>
  868. </tr>
  869. <tr>
  870. <td valign="top">bootclasspath</td>
  871. <td valign="top">location of bootstrap class files.</td>
  872. <td align="center" valign="top">No</td>
  873. </tr>
  874. <tr>
  875. <td valign="top">extdirs</td>
  876. <td valign="top">location of installed extensions.</td>
  877. <td align="center" valign="top">No</td>
  878. </tr>
  879. <tr>
  880. <td valign="top">debug</td>
  881. <td valign="top">indicates whether there should be compiled with debug
  882. information (&quot;on&quot;).</td>
  883. <td align="center" valign="top">No</td>
  884. </tr>
  885. <tr>
  886. <td valign="top">optimize</td>
  887. <td valign="top">indicates whether there should be compiled with
  888. optimization (&quot;on&quot;).</td>
  889. <td align="center" valign="top">No</td>
  890. </tr>
  891. <tr>
  892. <td valign="top">deprecation</td>
  893. <td valign="top">indicates whether there should be compiled with deprecation
  894. information (&quot;on&quot;).</td>
  895. <td align="center" valign="top">No</td>
  896. </tr>
  897. </table>
  898. <h3>Examples</h3>
  899. <blockquote>
  900. <p><code>&lt;javac srcdir=&quot;${src}&quot; destdir=&quot;${build}&quot; -classpath=&quot;xyz.jar&quot;
  901. -debug=&quot;on&quot; /&gt;</code></p>
  902. </blockquote>
  903. <hr>
  904. <h2><a name="javadoc">Javadoc/Javadoc2</a></h2>
  905. <h3>Description</h3>
  906. <p>Generates code documentation using the javadoc tool.</p>
  907. <p>The source directory will be recursively scanned for Java
  908. source files to but only those matching the inclusion rules will be passed to
  909. the javadoc tool. This allows wildcards to be used to choose between package
  910. names, reducing verbosity and management costs over time. This task, however,
  911. has no notion of &quot;changed&quot; files, unlike the <a href="#javac">javac</a>
  912. task, but it's not used so frequently.</p>
  913. <p>This task works seamlessly between different javadoc versions (1.1 and 1.2),
  914. with the obvious restriction that the 1.2 attributes will be ignored if run in a
  915. 1.1 VM.</p>
  916. <p>NOTE: since javadoc calls System.exit(), we cannot run javadoc inside the
  917. same VM without breaking functionality. For this reason, this task always forks
  918. the VM. But this is not a performance penalty since javadoc is normally a heavy
  919. application and must be called just once.</p>
  920. <p>DEPRECATION: the javadoc2 task simply points to the javadoc task and it's
  921. there for back compatibility reasons. Since this task will be removed in future
  922. versions, you are strongly encouraged to use <a href="#javadoc">javadoc</a>
  923. instead.</p>
  924. <h3>Parameters</h3>
  925. <table border="1" cellpadding="2" cellspacing="0">
  926. <tr>
  927. <td valign="top"><b>Attribute</b></td>
  928. <td valign="top"><b>Description</b></td>
  929. <td align="center" valign="top"><b>Availability</b></td>
  930. <td align="center" valign="top"><b>Required</b></td>
  931. </tr>
  932. <tr>
  933. <td valign="top">sourcepath</td>
  934. <td valign="top">Specify where to find source files</td>
  935. <td align="center" valign="top">all</td>
  936. <td align="center" valign="top">yes</td>
  937. </tr>
  938. <tr>
  939. <td valign="top">destdir</td>
  940. <td valign="top">Destination directory for output files</td>
  941. <td align="center" valign="top">all</td>
  942. <td align="center" valign="top">yes</td>
  943. </tr>
  944. <tr>
  945. <td valign="top">sourcefiles</td>
  946. <td valign="top">Space separated list of source files</td>
  947. <td align="center" valign="top">all</td>
  948. <td align="center" valign="middle" rowspan="2">at least one of the two</td>
  949. </tr>
  950. <tr>
  951. <td valign="top">packagenames</td>
  952. <td valign="top">Space separated list of package files (with terminating
  953. wildcard)</td>
  954. <td align="center" valign="top">all</td>
  955. </tr>
  956. <tr>
  957. <td valign="top">Classpath</td>
  958. <td valign="top">Specify where to find user class files</td>
  959. <td align="center" valign="top">all</td>
  960. <td align="center" valign="top">no</td>
  961. </tr>
  962. <tr>
  963. <td valign="top">Bootclasspath</td>
  964. <td valign="top">Override location of class files loaded by the bootstrap class loader</td>
  965. <td align="center" valign="top">1.2</td>
  966. <td align="center" valign="top">no</td>
  967. </tr>
  968. <tr>
  969. <td valign="top">Extdirs</td>
  970. <td valign="top">Override location of installed extensions</td>
  971. <td align="center" valign="top">1.2</td>
  972. <td align="center" valign="top">no</td>
  973. </tr>
  974. <tr>
  975. <td valign="top">Overview</td>
  976. <td valign="top">Read overview documentation from HTML file</td>
  977. <td align="center" valign="top">1.2</td>
  978. <td align="center" valign="top">no</td>
  979. </tr>
  980. <tr>
  981. <td valign="top">Public</td>
  982. <td valign="top">Show only public classes and members</td>
  983. <td align="center" valign="top">all</td>
  984. <td align="center" valign="top">no</td>
  985. </tr>
  986. <tr>
  987. <td valign="top">Protected</td>
  988. <td valign="top">Show protected/public classes and members (default)</td>
  989. <td align="center" valign="top">all</td>
  990. <td align="center" valign="top">no</td>
  991. </tr>
  992. <tr>
  993. <td valign="top">Package</td>
  994. <td valign="top">Show package/protected/public classes and members</td>
  995. <td align="center" valign="top">all</td>
  996. <td align="center" valign="top">no</td>
  997. </tr>
  998. <tr>
  999. <td valign="top">Private</td>
  1000. <td valign="top">Show all classes and members</td>
  1001. <td align="center" valign="top">all</td>
  1002. <td align="center" valign="top">no</td>
  1003. </tr>
  1004. <tr>
  1005. <td valign="top">Old</td>
  1006. <td valign="top">Generate output using JDK 1.1 emulating doclet</td>
  1007. <td align="center" valign="top">1.2</td>
  1008. <td align="center" valign="top">no</td>
  1009. </tr>
  1010. <tr>
  1011. <td valign="top">Verbose</td>
  1012. <td valign="top">Output messages about what Javadoc is doing</td>
  1013. <td align="center" valign="top">1.2</td>
  1014. <td align="center" valign="top">no</td>
  1015. </tr>
  1016. <tr>
  1017. <td valign="top">Locale</td>
  1018. <td valign="top">Locale to be used, e.g. en_US or en_US_WIN</td>
  1019. <td align="center" valign="top">1.2</td>
  1020. <td align="center" valign="top">no</td>
  1021. </tr>
  1022. <tr>
  1023. <td valign="top">Encoding</td>
  1024. <td valign="top">Source file encoding name</td>
  1025. <td align="center" valign="top">all</td>
  1026. <td align="center" valign="top">no</td>
  1027. </tr>
  1028. <tr>
  1029. <td valign="top">Version</td>
  1030. <td valign="top">Include @version paragraphs</td>
  1031. <td align="center" valign="top">all</td>
  1032. <td align="center" valign="top">no</td>
  1033. </tr>
  1034. <tr>
  1035. <td valign="top">Use</td>
  1036. <td valign="top">Create class and package usage pages</td>
  1037. <td align="center" valign="top">1.2</td>
  1038. <td align="center" valign="top">no</td>
  1039. </tr>
  1040. <tr>
  1041. <td valign="top">Author</td>
  1042. <td valign="top">Include @author paragraphs</td>
  1043. <td align="center" valign="top">all</td>
  1044. <td align="center" valign="top">no</td>
  1045. </tr>
  1046. <tr>
  1047. <td valign="top">Splitindex</td>
  1048. <td valign="top"> Split index into one file per letter</td>
  1049. <td align="center" valign="top">1.2</td>
  1050. <td align="center" valign="top">no</td>
  1051. </tr>
  1052. <tr>
  1053. <td valign="top">Windowtitle</td>
  1054. <td valign="top">Browser window title for the documenation (text)</td>
  1055. <td align="center" valign="top">1.2</td>
  1056. <td align="center" valign="top">no</td>
  1057. </tr>
  1058. <tr>
  1059. <td valign="top">Doctitle</td>
  1060. <td valign="top"> Include title for the package index(first) page
  1061. (html-code)</td>
  1062. <td align="center" valign="top">1.2</td>
  1063. <td align="center" valign="top">no</td>
  1064. </tr>
  1065. <tr>
  1066. <td valign="top">Header</td>
  1067. <td valign="top"> Include header text for each page (html-code)</td>
  1068. <td align="center" valign="top">1.2</td>
  1069. <td align="center" valign="top">no</td>
  1070. </tr>
  1071. <tr>
  1072. <td valign="top">Footer</td>
  1073. <td valign="top"> Include footer text for each page (html-code)</td>
  1074. <td align="center" valign="top">1.2</td>
  1075. <td align="center" valign="top">no</td>
  1076. </tr>
  1077. <tr>
  1078. <td valign="top">bottom</td>
  1079. <td valign="top"> Include bottom text for each page (html-code)</td>
  1080. <td align="center" valign="top">1.2</td>
  1081. <td align="center" valign="top">no</td>
  1082. </tr>
  1083. <tr>
  1084. <td valign="top">link</td>
  1085. <td valign="top"> Create links to javadoc output at the given
  1086. URL</td>
  1087. <td align="center" valign="top">1.2</td>
  1088. <td align="center" valign="top">no</td>
  1089. </tr>
  1090. <tr>
  1091. <td valign="top">linkoffline</td>
  1092. <td valign="top"> Link to docs at &lt;url&gt; using package list at &lt;url2></td>
  1093. <td align="center" valign="top">1.2</td>
  1094. <td align="center" valign="top">no</td>
  1095. </tr>
  1096. <tr>
  1097. <td valign="top">group</td>
  1098. <td valign="top"> Group specified packages together in overview page</td>
  1099. <td align="center" valign="top">1.2</td>
  1100. <td align="center" valign="top">no</td>
  1101. </tr>
  1102. <tr>
  1103. <td valign="top">nodeprecated</td>
  1104. <td valign="top"> Do not include @deprecated information</td>
  1105. <td align="center" valign="top">all</td>
  1106. <td align="center" valign="top">no</td>
  1107. </tr>
  1108. <tr>
  1109. <td valign="top">nodeprecatedlist</td>
  1110. <td valign="top"> Do not generate deprecated list</td>
  1111. <td align="center" valign="top">1.2</td>
  1112. <td align="center" valign="top">no</td>
  1113. </tr>
  1114. <tr>
  1115. <td valign="top">notree</td>
  1116. <td valign="top"> Do not generate class hierarchy</td>
  1117. <td align="center" valign="top">all</td>
  1118. <td align="center" valign="top">no</td>
  1119. </tr>
  1120. <tr>
  1121. <td valign="top">noindex</td>
  1122. <td valign="top"> Do not generate index</td>
  1123. <td align="center" valign="top">all</td>
  1124. <td align="center" valign="top">no</td>
  1125. </tr>
  1126. <tr>
  1127. <td valign="top">nohelp</td>
  1128. <td valign="top"> Do not generate help link</td>
  1129. <td align="center" valign="top">1.2</td>
  1130. <td align="center" valign="top">no</td>
  1131. </tr>
  1132. <tr>
  1133. <td valign="top">nonavbar</td>
  1134. <td valign="top"> Do not generate navigation bar</td>
  1135. <td align="center" valign="top">1.2</td>
  1136. <td align="center" valign="top">no</td>
  1137. </tr>
  1138. <tr>
  1139. <td valign="top">serialwarn</td>
  1140. <td valign="top"> Generate warning about @serial tag</td>
  1141. <td align="center" valign="top">1.2</td>
  1142. <td align="center" valign="top">no</td>
  1143. </tr>
  1144. <tr>
  1145. <td valign="top">helpfile</td>
  1146. <td valign="top">Specifies the HTML help file to use</td>
  1147. <td align="center" valign="top">1.2</td>
  1148. <td align="center" valign="top">no</td>
  1149. </tr>
  1150. <tr>
  1151. <td valign="top">stylesheetfile</td>
  1152. <td valign="top">Specifies the CSS stylesheet to use</td>
  1153. <td align="center" valign="top">1.2</td>
  1154. <td align="center" valign="top">no</td>
  1155. </tr>
  1156. <tr>
  1157. <td valign="top">charset</td>
  1158. <td valign="top"> Charset for cross-platform viewing of generated documentation</td>
  1159. <td align="center" valign="top">1.2</td>
  1160. <td align="center" valign="top">no</td>
  1161. </tr>
  1162. <tr>
  1163. <td valign="top">docencoding</td>
  1164. <td valign="top">Output file encoding name</td>
  1165. <td align="center" valign="top">1.1</td>
  1166. <td align="center" valign="top">no</td>
  1167. </tr>
  1168. </table>
  1169. <h3>Examples</h3>
  1170. <blockquote>
  1171. <pre>&lt;javadoc packagenames=&quot;com.dummy.test.*&quot;
  1172. sourcepath=&quot;src&quot;
  1173. destdir=&quot;docs/api&quot;
  1174. author=&quot;true&quot;
  1175. version=&quot;true&quot;
  1176. use=&quot;true&quot;
  1177. windowtitle=&quot;Test API&quot;
  1178. doctitle=&quot;&lt;h1&gt;Test&lt;/h1&gt;&quot;
  1179. bottom=&quot;&lt;i&gt;Copyright &amp;#169; 2000 Dummy Corp. All Rights Reserved.&lt;/i&gt;&quot;
  1180. /&gt;</pre>
  1181. </blockquote>
  1182. <hr>
  1183. <h2><a name="keysubst">KeySubst</a></h2>
  1184. <h3>Description</h3>
  1185. <p>Performs keyword substitution in the source file, and writes the result to
  1186. the destination file.</p>
  1187. <p>Keys in the source file are of the form ${keyname}. The <i>keys</i> attribute
  1188. contains key/value pairs. When a key is found in the <i>keys</i> attribute, then
  1189. &quot;${keyname}&quot; is replaced by the corresponding value.</p>
  1190. <p>The <i>keys</i> attribute is of the form
  1191. &quot;name1=value1*name2=value2*name3=value3&quot;. The '*' is called the
  1192. separator, which might we changed with the <i>sep</i> attribute.</p>
  1193. <p>Note: the source file and destination file may not be the same.</p>
  1194. <h3>Parameters</h3>
  1195. <table border="1" cellpadding="2" cellspacing="0">
  1196. <tr>
  1197. <td valign="top"><b>Attribute</b></td>
  1198. <td valign="top"><b>Description</b></td>
  1199. <td align="center" valign="top"><b>Required</b></td>
  1200. </tr>
  1201. <tr>
  1202. <td valign="top">src</td>
  1203. <td valign="top">the source file.</td>
  1204. <td align="center" valign="top">Yes</td>
  1205. </tr>
  1206. <tr>
  1207. <td valign="top">dest</td>
  1208. <td valign="top">the destination file.</td>
  1209. <td align="center" valign="top">Yes</td>
  1210. </tr>
  1211. <tr>
  1212. <td valign="top">sep</td>
  1213. <td valign="top">the separator for the name/value pairs.</td>
  1214. <td align="center" valign="top">No</td>
  1215. </tr>
  1216. <tr>
  1217. <td valign="top">keys</td>
  1218. <td valign="top">name/value pairs for replacement.</td>
  1219. <td align="center" valign="top">Yes</td>
  1220. </tr>
  1221. </table>
  1222. <h3>Examples</h3>
  1223. <blockquote>
  1224. <p><code>&lt;keysubst src=&quot;abc.txt&quot; dest=&quot;def.txt&quot;
  1225. keys=&quot;VERSION=1.0.3*DATE=2000-01-10&quot; /&gt;</code></p>
  1226. </blockquote>
  1227. <hr>
  1228. <h2><a name="mkdir">Mkdir</a></h2>
  1229. <h3>Description</h3>
  1230. <p>Creates a directory. Also non-existent parent directories are created, when
  1231. necessary.</p>
  1232. <h3>Parameters</h3>
  1233. <table border="1" cellpadding="2" cellspacing="0">
  1234. <tr>
  1235. <td valign="top"><b>Attribute</b></td>
  1236. <td valign="top"><b>Description</b></td>
  1237. <td align="center" valign="top"><b>Required</b></td>
  1238. </tr>
  1239. <tr>
  1240. <td valign="top">dir</td>
  1241. <td valign="top">the directory to create.</td>
  1242. <td align="center" valign="top">Yes</td>
  1243. </tr>
  1244. </table>
  1245. <h3>Examples</h3>
  1246. <blockquote>
  1247. <p><code>&lt;mkdir dir=&quot;${dist}&quot; /&gt;</code></p>
  1248. <p><code>&lt;mkdir dir=&quot;${dist}/lib&quot; /&gt;</code></p>
  1249. </blockquote>
  1250. <hr>
  1251. <h2><a name="property">Property</a></h2>
  1252. <h3>Description</h3>
  1253. <p>Sets a property (by name and value), or set of properties (from file or
  1254. resource) in the project.</p>
  1255. <p>When a property was set by the user, or was a property in a parent project
  1256. (that started this project with the <a href="#ant">ant task</a>), then this
  1257. property cannot be set, and will be ignored. This means that properties set
  1258. outside the current project always override the properties of the current
  1259. project.</p>
  1260. <p>There are three ways to set properties:</p>
  1261. <ul>
  1262. <li>By supplying both the <i>name</i> and <i>value</i> attribute.</li>
  1263. <li>By setting the <i>file</i> attribute with the filename of the property
  1264. file to load. This property file has the format as defined by the file used
  1265. in the class java.util.Properties.</li>
  1266. <li>By setting the <i>resource</i> attribute with the resource name of the
  1267. property file to load. This property file has the format as defined by the
  1268. file used in the class java.util.Properties.</li>
  1269. </ul>
  1270. <p>Although combinations of the three ways are possible, only one should be used
  1271. at a time. Problems might occur with the order in which properties are set, for
  1272. instance.</p>
  1273. <p>The value part of the properties being set, might contain references to other
  1274. properties. These references are resolved at the time these properties are set.
  1275. This also holds for properties loaded from a property file.</p>
  1276. <h3>Parameters</h3>
  1277. <table border="1" cellpadding="2" cellspacing="0">
  1278. <tr>
  1279. <td valign="top"><b>Attribute</b></td>
  1280. <td valign="top"><b>Description</b></td>
  1281. <td align="center" valign="top"><b>Required</b></td>
  1282. </tr>
  1283. <tr>
  1284. <td valign="top">name</td>
  1285. <td valign="top">the name of the property to set.</td>
  1286. <td valign="top" align="center">No</td>
  1287. </tr>
  1288. <tr>
  1289. <td valign="top">value</td>
  1290. <td valign="top">the value of the property.</td>
  1291. <td valign="top" align="center">No</td>
  1292. </tr>
  1293. <tr>
  1294. <td valign="top">resource</td>
  1295. <td valign="top">the resource name of the property file.</td>
  1296. <td valign="top" align="center">No</td>
  1297. </tr>
  1298. <tr>
  1299. <td valign="top">file</td>
  1300. <td valign="top">the filename of the property file .</td>
  1301. <td valign="top" align="center">No</td>
  1302. </tr>
  1303. </table>
  1304. <h3>Examples</h3>
  1305. <blockquote>
  1306. <p><code>&lt;property name=&quot;foo.dist&quot; value=&quot;dist&quot;/&gt;</code></p>
  1307. <p><code>&lt;property file=&quot;foo.properties&quot; /&gt;</code></p>
  1308. <p><code>&lt;property resource=&quot;foo.properties&quot; /&gt;</code></p>
  1309. </blockquote>
  1310. <hr>
  1311. <h2><a name="replace">Replace</a></h2>
  1312. <h3>Description</h3>
  1313. <p>Replaces the occurrence of a given string with another string in a file. When
  1314. the <i>value</i> attribute is omitted, it defaults to &quot;&quot;.</p>
  1315. <h3>Parameters</h3>
  1316. <table border="1" cellpadding="2" cellspacing="0">
  1317. <tr>
  1318. <td valign="top"><b>Attribute</b></td>
  1319. <td valign="top"><b>Description</b></td>
  1320. <td align="center" valign="top"><b>Required</b></td>
  1321. </tr>
  1322. <tr>
  1323. <td valign="top">file</td>
  1324. <td valign="top">file for which the token should be replaced</td>
  1325. <td valign="top" align="center">Yes</td>
  1326. </tr>
  1327. <tr>
  1328. <td valign="top">token</td>
  1329. <td valign="top">the token which must be replaced</td>
  1330. <td valign="top" align="center">Yes</td>
  1331. </tr>
  1332. <tr>
  1333. <td valign="top">value</td>
  1334. <td valign="top">the new value for the token</td>
  1335. <td valign="top" align="center">No</td>
  1336. </tr>
  1337. </table>
  1338. <h3>Examples</h3>
  1339. <blockquote>
  1340. <p><code>&lt;replace file=&quot;${src}/index.html&quot; token=&quot;@@@&quot;
  1341. value=&quot;wombat&quot; /&gt;</code></p>
  1342. </blockquote>
  1343. <hr>
  1344. <h2><a name="rmic">Rmic</a></h2>
  1345. <h3>Description</h3>
  1346. <p>Runs the rmic compiler for a certain class.</p>
  1347. <h3>Parameters</h3>
  1348. <table border="1" cellpadding="2" cellspacing="0">
  1349. <tr>
  1350. <td valign="top"><b>Attribute</b></td>
  1351. <td valign="top"><b>Description</b></td>
  1352. <td align="center" valign="top"><b>Required</b></td>
  1353. </tr>
  1354. <tr>
  1355. <td valign="top">base</td>
  1356. <td valign="top">the location to store the compiled files.</td>
  1357. <td valign="top" align="center">Yes</td>
  1358. </tr>
  1359. <tr>
  1360. <td valign="top">class</td>
  1361. <td valign="top">the class for which to run <code>rmic</code>.</td>
  1362. <td valign="top" align="center">Yes</td>
  1363. </tr>
  1364. </table>
  1365. <h3>Examples</h3>
  1366. <blockquote>
  1367. <p><code>&lt;rmic class=&quot;com.xyz.FooBar&quot;
  1368. base=&quot;${build}/classes&quot; /&gt;</code></p>
  1369. </blockquote>
  1370. <hr>
  1371. <h2><a name="taskdef">Taskdef</a></h2>
  1372. <h3>Description</h3>
  1373. <p>Adds a task definition to the current project, such that this new task can be
  1374. used in the current project. Two attributes are needed, the name that identifies
  1375. this task uniquely, and the full name of the class (including the packages) that
  1376. implements this task.</p>
  1377. <p>Taskdef should be used to add your own tasks to the system. See also &quot;<a
  1378. href="#writingowntask">Writing your own task</a>&quot;.</p>
  1379. <h3>Parameters</h3>
  1380. <table border="1" cellpadding="2" cellspacing="0">
  1381. <tr>
  1382. <td valign="top"><b>Attribute</b></td>
  1383. <td valign="top"><b>Description</b></td>
  1384. <td align="center" valign="top"><b>Required</b></td>
  1385. </tr>
  1386. <tr>
  1387. <td valign="top">name</td>
  1388. <td valign="top">the name of the task</td>
  1389. <td valign="top" align="center">Yes</td>
  1390. </tr>
  1391. <tr>
  1392. <td valign="top">class</td>
  1393. <td valign="top">the full class name implementing the task</td>
  1394. <td valign="top" align="center">Yes</td>
  1395. </tr>
  1396. </table>
  1397. <h3>Examples</h3>
  1398. <blockquote>
  1399. <p><code>&lt;taskdef name=&quot;myjavadoc&quot; value=&quot;com.mydomain.JavadocTask&quot;
  1400. /&gt;</code></p>
  1401. </blockquote>
  1402. <hr>
  1403. <h2><a name="tstamp">Tstamp</a></h2>
  1404. <h3>Description</h3>
  1405. <p>Sets the DSTAMP, TSTAMP and TODAY properties in the current project. The DSTAMP is
  1406. in the &quot;yyyymmdd&quot; format, the TSTAMP is in the &quot;hhmm&quot; format
  1407. and TODAY is &quot;month day year&quot;.</p>
  1408. <p>These properties can be used in the buildfile, for instance, to create
  1409. timestamped filenames or used to replace placeholder tags inside documents to
  1410. indicate, for example, the release date. The best place for this task is in the <a
  1411. href="#inittarget">init target</a>.</p>
  1412. <h3>Parameters</h3>
  1413. <table border="1" cellpadding="2" cellspacing="0">
  1414. <tr>
  1415. <td valign="top"><b>Attribute</b></td>
  1416. <td valign="top"><b>Description</b></td>
  1417. <td align="center" valign="top"><b>Required</b></td>
  1418. </tr>
  1419. </table>
  1420. <h3>Examples</h3>
  1421. <blockquote>
  1422. <p><code>&lt;tstamp/&gt;</code></p>
  1423. </blockquote>
  1424. <hr>
  1425. <h2><a name="zip">Zip</a></h2>
  1426. <h3>Description</h3>
  1427. <p>Creates a zipfile.</p>
  1428. <p>The <i>basedir</i> attribute is the reference directory from where to zip.</p>
  1429. <p>When &quot;*&quot; is used for items, all files in the basedir, and its
  1430. subdirectories, will be zipped. Otherwise all the files and directories
  1431. mentioned in the items list will zipped. When a directory is specified, then all
  1432. files within it are also zipped.</p>
  1433. <p>With the <i>ignore</i> attribute, you can specify names of files or
  1434. directories to ignore. These files will not be zipped. The items in the <i>ignore</i>
  1435. attribute override the items in the <i>items</i> attribute. The names specified
  1436. in the <i>ignore</i> attribute are just names, they do not contain any path
  1437. information!</p>
  1438. <h3>Parameters</h3>
  1439. <table border="1" cellpadding="2" cellspacing="0">
  1440. <tr>
  1441. <td valign="top"><b>Attribute</b></td>
  1442. <td valign="top"><b>Description</b></td>
  1443. <td valign="top" align="center"><b>Required</b></td>
  1444. </tr>
  1445. <tr>
  1446. <td valign="top">zipfile</td>
  1447. <td valign="top">the zip-file to create.</td>
  1448. <td align="center" valign="top">Yes</td>
  1449. </tr>
  1450. <tr>
  1451. <td valign="top">basedir</td>
  1452. <td valign="top">the directory from which to zip the files.</td>
  1453. <td align="center" valign="top">Yes</td>
  1454. </tr>
  1455. <tr>
  1456. <td valign="top">items</td>
  1457. <td valign="top">a comma separated list of the files/directories to zip.</td>
  1458. <td align="center" valign="top">Yes</td>
  1459. </tr>
  1460. <tr>
  1461. <td valign="top">ignore</td>
  1462. <td valign="top">a comma separated list of the filenames/directorynames to
  1463. exclude from the zip.</td>
  1464. <td align="center" valign="top">No</td>
  1465. </tr>
  1466. </table>
  1467. <h3>Examples</h3>
  1468. <blockquote>
  1469. <p><code>&lt;zip zipfile=&quot;${dist}/manual.zip&quot; basedir=&quot;htdocs/manual&quot;
  1470. items=&quot;*&quot; /&gt;</code></p>
  1471. </blockquote>
  1472. <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
  1473. in the <code>${dist}</code> directory.</p>
  1474. <blockquote>
  1475. <p><code>&lt;zip zipfile=&quot;${dist}/manual.zip&quot; basedir=&quot;htdocs/manual&quot;
  1476. items=&quot;*&quot; ignore=&quot;mydocs, todo.html&quot;/&gt;</code></p>
  1477. </blockquote>
  1478. <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
  1479. in the <code>${dist}</code> directory. Files/directories with the names <code>mydocs</code>
  1480. and <code>todo.html</code> are excluded.</p>
  1481. <hr>
  1482. <h2><a name="writingowntask">Writing your own task</a></h2>
  1483. <p>It is very easy to write your own task:</p>
  1484. <ol>
  1485. <li>Create a Java class that extends <code>org.apache.tools.ant.Task</code>.</li>
  1486. <li>For each attribute, write a setter method. The setter method must be a <code>public
  1487. void</code> method that takes one <code>String</code> as an argument. The
  1488. name of the method must begin with &quot;set&quot;, followed by the
  1489. attribute name, with the first character in uppercase, and the rest in
  1490. lowercase.</li>
  1491. <li>Write a <code>public void execute</code> method, with no arguments, that
  1492. throws a <code>BuildException</code>. This method implements the task
  1493. itself.</li>
  1494. </ol>
  1495. <p>It is important to know that Ant first calls the setters for the attributes
  1496. it encounters for a specific task in the buildfile, before it executes is.</p>
  1497. <p>Let's write our own task, that prints a message on the System.out stream. The
  1498. task has one attribute called &quot;message&quot;.</p>
  1499. <blockquote>
  1500. <pre>public class MyVeryOwnTask extends Task {
  1501. private String msg;
  1502. // The method executing the task
  1503. public void execute() throws BuildException {
  1504. System.out.println(message);
  1505. }
  1506. // The setter for the &quot;message&quot; attribute
  1507. public void setMessage(String msg) {
  1508. this.msg = msg;
  1509. }
  1510. }</pre>
  1511. </blockquote>
  1512. <p>It's really this simple;-)</p>
  1513. <p>Adding your task to the system is rather simple too:</p>
  1514. <ol>
  1515. <li>Make sure the class that implements your task is in the classpath when
  1516. starting Ant.</li>
  1517. <li>In the <i>init</i> target, add a <i>taskdef</i> task. This actually adds
  1518. your task to the system.</li>
  1519. <li>Use your task in the rest of the buildfile.</li>
  1520. </ol>
  1521. <h3>Example</h3>
  1522. <blockquote>
  1523. <pre>&lt;project name=&quot;TaskTest&quot; default=&quot;test&quot; basedir=&quot;.&quot;&gt;
  1524. &lt;target name=&quot;init&quot;&gt;
  1525. &lt;taskdef name=&quot;mytask&quot; class=&quot;com.mydomain.MyVeryOwnTask&quot;/&gt;
  1526. &lt;/target&gt;
  1527. &lt;target name=&quot;test&quot;&gt;
  1528. &lt;mytask myattr=&quot;wombat&quot; /&gt;
  1529. &lt;/target&gt;
  1530. &lt;/project&gt;
  1531. </pre>
  1532. </blockquote>
  1533. <p>Another way to add a task (more permanently), is to add the task name and
  1534. implementing class name to the <code>default.properties</code> file in the <code>org.apache.tools.ant.taskdefs</code>
  1535. package. Then you can use it as if it were a built in task.</p>
  1536. <hr>
  1537. <h2><a name="feedback">Feedback</a></h2>
  1538. <p>To provide feedback on this software, please subscribe to the Ant Development
  1539. Mail List <a href="mailto:(ant-dev-subscribe@jakarta.apache.org">(ant-dev-subscribe@jakarta.apache.org</a>)</p>
  1540. <hr>
  1541. <p align="center">Copyright &copy; 2000 Apache Software Foundation. All
  1542. rights Reserved.</p>
  1543. </body>
  1544. </html>