|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821 |
- <html>
-
- <head>
- <meta http-equiv="Content-Language" content="en-us">
- <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
- <meta name="ProgId" content="FrontPage.Editor.Document">
- <title>Ant</title>
- </head>
-
- <body>
-
- <h1>Ant User Manual</h1>
- <p>by</p>
- <!-- Names are in alphabetical order, on last name -->
- <ul>
- <li>James Duncan Davison (<a href="mailto:(duncan@x180.com">duncan@x180.com</a>)</li>
- <li>Arnout J. Kuiper (<a href="mailto:(ajkuiper@wxs.nl">ajkuiper@wxs.nl</a>)</li>
- <li>Stefano Mazzocchi (<a href="mailto:(stefano@apache.org">stefano@apache.org</a>)</li>
- </ul>
- <p>Version 1.0.3 - 2000/02/06</p>
- <hr>
- <h2>Table of Contents</h2>
- <ul>
- <li><a href="#introduction">Introduction</a></li>
- <li><a href="#getting">Getting Ant</a></li>
- <li><a href="#buildingant">Building Ant</a></li>
- <li><a href="#installing">Installing Ant</a></li>
- <li><a href="#running">Running Ant</a></li>
- <li><a href="#buildfile">Writing a simple buildfile</a>
- <li><a href="#directorybasedtasks">Directory based tasks</a></li>
- <li><a href="#tasks">Built in Tasks</a>
- <li><a href="#writingowntask">Writing your own task</a></li>
- <li><a href="#license">License</a></li>
- <li><a href="#feedback">Feedback</a></li>
- </ul>
- <hr>
- <h2><a name="introduction">Introduction</a></h2>
- <p>Ant is a Java based build tool. In theory it is kind of like make without
- makes wrinkles.</p>
- <h3>Why?</h3>
- <p>Why another build tool when there is already make, gnumake, nmake, jam, and
- others? Because all of those tools have limitations that its original author
- couldn't live with when developing software across multiple platforms. Make like
- tools are inherently shell based. They evaluate a set of dependencies and then
- execute commands not unlike what you would issue on a shell. This means that you
- can easily extend these tools by using or writing any program for the OS that
- you are working on. However, this also means that you limit yourself to the OS,
- or at least the OS type such as Unix, that you are working on.</p>
- <p>Makefiles are inherently evil as well. Anybody who has worked on them for any
- time has run into the dreaded tab problem. "Is my command not executing
- because I have a space in front of my tab!!!" said the original author of
- Ant way too many times. Tools like Jam took care of this to a great degree, but
- still use yet another format to use and remember.</p>
- <p>Ant is different. Instead a model where it is extended with shell based
- commands, it is extended using Java classes. Instead of writing shell commands,
- the configuration files are XML based calling out a target tree where various
- tasks get executed. Each task is run by an object which implements a particular
- Task interface.</p>
- <p>Granted, this removes some of the expressive power that is inherent by being
- able to construct a shell command such as `find . -name foo -exec rm {}` but it
- gives you the ability to be cross platform. To work anywhere and everywhere. And
- hey, if you really need to execute a shell command, Ant has an exec rule that
- allows different commands to be executed based on the OS that it is executing
- on.</p>
- <hr>
- <h2><a name="getting">Getting Ant</a></h2>
- <h3>Binary edition</h3>
- <p>The latest stable version of Ant can be downloaded from <a
- href="http://jakarta.apache.org/builds/tomcat/release/v3.0/ant.zip">http://jakarta.apache.org/builds/tomcat/release/v3.0/ant.zip</a>.
- If you like living on the edge, you can download the latest version from <a
- href="http://jakarta.apache.org/builds/tomcat/nightly/ant.zip">http://jakarta.apache.org/builds/tomcat/nightly/ant.zip</a>.</p>
- <h3>Source edition</h3>
- <p>If you prefer the source edition, you can download Ant from <a
- 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>
- (latest stable) or from <a
- href="http://jakarta.apache.org/from-cvs/jakarta-tools/">http://jakarta.apache.org/from-cvs/jakarta-ant/</a>
- (current). See the section <a href="#buildingant">Building Ant</a> on how to
- build Ant from the source code.</p>
- <hr>
- <h2><a name="buildingant">Building Ant</a></h2>
- <p>Go to the directory <code>jakarta-ant</code>.</p>
- <p>Make sure the JDK is in you path.</p>
- <p>Run <code>bootstrap.bat</code> (Windows) or <code>bootstrap.sh</code> (UNIX)
- to build a bootstrap version of Ant.</p>
- <p>When finished, use</p>
- <blockquote>
- <p><code>build.bat -Ddist.dir=<directory to install Ant> dist</code></p>
- </blockquote>
- <p>for Windows, and</p>
- <blockquote>
- <p><code>build.sh -Ddist.dir=<directory to install Ant> dist</code></p>
- </blockquote>
- <p>for UNIX, to create a binary distribution of Ant. This distribution can be
- found in the directory you specified.</p>
- <hr>
- <h2><a name="installing">Installing Ant</a></h2>
- <p>The binary distribution of Ant consists of three directories: <code>bin</code>,
- <code>docs</code> and <code>lib</code>. Only the <code>bin</code> and <code>lib</code>
- directory are crucial for running Ant. To run Ant, the following must be done:</p>
- <ul>
- <li>Add the <code>bin</code> directory to your path.</li>
- <li>Set the ANT_HOME environment variable. This should be set to the directory
- which contains the <code>bin</code> and <code>lib</code> directory.</li>
- <li>Set the JAVA_HOME environment variable. This should be set to the
- directory where the JDK is installed.</li>
- </ul>
- <h3>Windows</h3>
- <p>Assume Ant is installed in <code>c:\ant\</code>. The following sets up the
- environment:</p>
- <pre>set ANT_HOME=c:\ant
- set JAVA_HOME=c:\jdk1.2.2
- set PATH=%PATH%;%ANT_HOME%\bin</pre>
- <h3>Unix (bash)</h3>
- <p>Assume Ant is installed in <code>/usr/local/ant</code>. The following sets up
- the environment:</p>
- <pre>export ANT_HOME=/usr/local/ant
- export JAVA_HOME=/usr/local/jdk-1.2.2
- export PATH=${PATH}:${ANT_HOME}/bin</pre>
- <h3>Advanced</h3>
- <p>There are lots of variants that can be used to run Ant. What you need is at
- least the following:</p>
- <p>The classpath for Ant must contain <code>ant.jar</code> and <code>xml.jar</code>.</p>
- <p>When you need JDK functionality (like a <a href="#javac">javac</a> task, or a
- <a href="#rmic">rmic</a> task), then for JDK 1.1, the <code>classes.zip</code>
- file of the JDK must be added to the classpath; for JDK 1.2, <code>tools.jar</code>
- must be added.</p>
- <p>When you are executing platform specific applications (like the <a
- href="#exec">exec</a> task, or the <a href="#cvs">cvs</a> task), the property <code>ant.home</code>
- 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>
- <hr>
- <h2><a name="running">Running Ant</a></h2>
- <p>Running Ant is simple, when you installed it as described in the previous
- section. Just type <code>ant</code>.</p>
- <p>When nothing is specified, Ant looks for a <code>build.xml</code> file in the
- current directory. When found, it uses that file as a buildfile. To make Ant use
- another buildfile, use the commandline option <i>-buildfile <file></i>,
- where <i><file></i> is the buildfile you want to use.</p>
- <p>You can also set properties which override properties specified in the
- buildfile. This can be done with the <i>-D<property>=<value></i>
- option, where <i><property></i> is the name of the property and <i><value></i>
- the value.</p>
- <p>To more options are <i>-quiet</i> which instructs Ant to print less
- information on the console when running. The option <i>-verbose</i> on the other
- hand makes Ant print more information on the console.</p>
- <p>It is also possible to specify the target that should be executed. Default
- the target that is mentioned in the <i>default</i> attribute of the project is
- used. This can be overridden by adding the target name to the end of the
- commandline.</p>
- <p>Commandline option summary:</p>
- <pre>ant [options] [target]
- Options:
- -help print this message
- -quiet be extra quiet
- -verbose be extra verbose
- -logfile <file> use given file for log
- -buildfile <file> use given buildfile
- -D<property>=<value> use value for given property</pre>
- <h3>Examples</h3>
- <blockquote>
- <pre>ant</pre>
- </blockquote>
- <p>runs Ant using the <code>build.xml</code> file in the current directory, on
- the default target.</p>
- <blockquote>
- <pre>ant -buildfile test.xml</pre>
- </blockquote>
- <p>runs Ant using the <code>test.xml</code> file in the current directory, on
- the default target.</p>
- <blockquote>
- <pre>ant -buildfile test.xml dist</pre>
- </blockquote>
- <p>runs Ant using the <code>test.xml</code> file in the current directory, on a
- target called <code>dist</code>.</p>
- <blockquote>
- <pre>ant -buildfile test.xml -Dbuild=build/classes dist</pre>
- </blockquote>
- <p>runs Ant using the <code>test.xml</code> file in the current directory, on a
- target called <code>dist</code>. It also sets the <i>build</i> property to the
- value <i>build/classes</i>.</p>
- <h3>Running Ant by hand</h3>
- <p>When you have installed Ant in the do-it-yourself way, Ant can be started
- with:</p>
- <blockquote>
- <pre>set CLASSPATH=c:\ant\lib\ant.jar;c:\ant\lib\xml.jar;c:\jdk1.2.2\lib\tools.jar
- java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]</pre>
- </blockquote>
- <p>These instructions actually do exactly the same as the <code>ant</code>
- command. The options and target are the same as when running Ant with the <code>ant</code>
- command.</p>
- <hr>
- <h2><a name="buildfile">Writing a simple buildfile</a></h2>
- <p>The buildfile is an written in XML. Each buildfile contains one project.</p>
- <h3>Projects</h3>
- <p>A project has three attributes:</p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">name</td>
- <td valign="top">the name of the project.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">default</td>
- <td valign="top">the default target to use when no target is supplied.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">basedir</td>
- <td valign="top">the base directory from which all path calculations are
- done. This attribute might be overridden by setting the "basedir"
- property on forehand. When this is done, it might be ommitted in the
- project tag.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- </table>
- <p>Each project defines one or more targets. A target is a set of tasks you want
- to be executed. When starting Ant, you can select which target you want to have
- executed. When no target is given, the project's default is used.</p>
- <h3>Targets</h3>
- <p>A target can depend on other targets. You might have a target for compiling,
- for instance, and a target for creating a distributable. You can only build a
- distributable when you have compiled first, so the distribute target depends on
- the compile target. Ant resolves all these dependencies.</p>
- <p>Ant tries to execute the targets in the <i>depends</i> attribute in the order
- they appear (from left to right). Keep in mind that it is possible that a target
- can get executed earlier when an earlier target depends on it:</p>
- <pre><target name="A"/>
- <target name="B" depends="A"/>
- <target name="C" depends="B"/>
- <target name="D" depends="C,B,A"/></pre>
- <p>Suppose we want to execute target D. From its <i>depends</i> attribute, you
- might think that first target C, then B and then A is executed. Wrong! C depends
- on B, and B depends on A, so first A is executed, then B, then C, and finally D.</p>
- <p>In situations without such dependencies, you can rely on the order of the
- targets in the <i>depends</i> attributes.</p>
- <p>A target gets executed only once. Even when more targets depend on it (see
- the previous example).</p>
- <p>A target has the following attributes:</p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">name</td>
- <td valign="top">the name of the project.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">depends</td>
- <td valign="top">a comma separated list of names of targets on which this
- target depends.</td>
- <td align="center" valign="top">No</td>
- </tr>
- </table>
- <h3>Tasks</h3>
- <p>A task is a piece of code that can be executed.</p>
- <p>A task can have multiple attributes (or arguments if you prefer). The value
- of an attribute might contain references to a property. These references will be
- resolved before the task is executed.</p>
- <p>Tasks have a common structure:</p>
- <blockquote>
- <pre><name attribute1="value1" attribute2="value2" ... /></pre>
- </blockquote>
- <p>where name is the name of the task, attribute-x the attribute name, and
- value-x the value of this attribute.</p>
- <p>There is a set of <a href="#tasks">built in tasks</a>, but it is also very
- easy to <a href="#writingowntask">write your own</a>.</p>
- <h3>Properties</h3>
- <p>A project can have a set of properties. These might be set in the buildfile
- by the <a href="#property">property task</a>, or might be set outside Ant. A
- property has a name and a value. Properties might be used in in the value of
- task attributes. This is done by placing the property name between
- "${" and "}" in the attribute value.</p>
- <p>If there is a property called "builddir" with the value
- "build", then this could be used in an attribute like this: "${builddir}/classes".
- This is resolved as "build/classes".</p>
- <h3>Examples</h3>
- <blockquote>
- <pre><project name="foo" default="dist" basedir=".">
- <target name="init">
- <tstamp/>
- <property name="build" value="build" />
- <property name="dist" value="dist" />
- </target>
-
- <target name="prepare" depends="init">
- <mkdir dir="${build}" />
- </target>
-
- <target name="compile" depends="prepare">
- <javac srcdir="${src}" destdir="${build}" />
- </target>
-
- <target name="dist" depends="compile">
- <mkdir dir="${dist}/lib" />
- <jar jarfile="${dist}/lib/foo${DSTAMP}.jar"
- basedir="${build}" items="com"/>
- </target>
-
- <target name="clean" depends="init">
- <deltree dir="${build}" />
- <deltree dir="${dist}" />
- </target>
- </project>
- </pre>
- </blockquote>
- <hr>
- <h2><a name="directorybasedtasks">Directory based tasks</a></h2>
- <p>Some tasks use directory trees for the task they perform. For instance, the <a
- href="#javac">Javac task</a> which works upon a directory tree with .java files.
- Sometimes it can be very useful to work on a subset of that directory tree. This
- section describes how you can select a subset of such a directory tree.</p>
- <p>Ant gives you two ways to create a subset, which both can be used at the same
- time:</p>
- <ul>
- <li>Only include files/directories that match at least one pattern of a set of
- patterns</li>
- <li>Exclude files/directories that match at least one pattern a set of
- patterns</li>
- </ul>
- <p>When both inclusion and exclusion are used, only files/directories that match
- the include patterns, and don't match the exclude patterns are used.</p>
- <h3>Patterns</h3>
- <p>As described earlier, patterns are used for the inclusion and exclusion.
- These patterns look very much like the patterns used in DOS and UNIX:</p>
- <p>'*' matches zero or more characters, '?' matches one character.</p>
- <p>Examples:</p>
- <p>'*.java' matches '.java', 'x.java' and 'FooBar.java', but not 'FooBar.xml'
- (does not end with '.java').</p>
- <p>'?.java' matches 'x.java', 'A.java', but not '.java' or 'xyz.java' (both
- don't have one character before '.java').</p>
- <p>Combinations of '*'s and '?'s are allowed.</p>
- <p>Matching is done per-directory. This means that first the first directory in
- the pattern is matched against the first directory in the path to match. Then
- the second directories are matched, and so on. E.g. when we have the pattern '/?abc/*/*.java'
- and the path '/xabc/foobar/test.java', then first '?abc' is matched with 'xabc',
- then '*' is matched with 'foobar' and finally '*.java' is matched with 'test.java'.
- They all match so the path matches the pattern.</p>
- <p>Too make things a bit more flexible, we add one extra feature, which makes it
- possible to match multiple directory levels. This can be used to match a
- complete directory tree, or a file anywhere in the directory tree. To do this, '**'
- must be used as the name of a directory. When '**' is used as the name of a
- directory in the pattern, it matches zero or more directories. For instance:
- '/test/**' matches all files/directories under '/test/', such as '/test/x.java',
- or '/test/foo/bar/xyz.html', but not '/xyz.xml'.</p>
- <p>There is one "shorthand", if a pattern ends with '/' or '\', then '**'
- is appended. E.g. "mypackage/test/" is interpreted as were it "mypackage/test/**".</p>
- <p>Examples:</p>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top">**/CVS/*</td>
- <td valign="top">Matches all files in CVS directories, that can be located
- anywhere in the directory tree.
- <p>Matches:</p>
- <p>CVS/Repository<br>
- org/apache/CVS/Entries<br>
- org/apache/jakarta/tools/ant/CVS/Entries</p>
- <p>But not:</p>
- <p>org/apache/CVS/foo/bar/Entries ('foo/bar/' part does not match)</td>
- </tr>
- <tr>
- <td valign="top">org/apache/jakarta/**</td>
- <td valign="top">Matches all files in the org/apache/jakarta directory tree.
- <p>Matches:</p>
- <p>org/apache/jakarta/tools/ant/docs/index.html<br>
- org/apache/jakarta/test.xml</p>
- <p>But not:</p>
- <p>org/apache/xyz.java ('jakarta'/' part is missing)</td>
- </tr>
- <tr>
- <td valign="top">org/apache/**/CVS/*</td>
- <td valign="top">Matches all files in CVS directories, that are located
- anywhere in the directory tree under org/apache.
- <p>Matches:</p>
- <p>org/apache/CVS/Entries<br>
- org/apache/jakarta/tools/ant/CVS/Entries</p>
- <p>But not:</p>
- <p>org/apache/CVS/foo/bar/Entries ('foo/bar/' part does not match)</td>
- </tr>
- <tr>
- <td valign="top">**/test/**</td>
- <td valign="top">Matches all files which have a directory 'test' in their
- path, including 'test' as a filename.</td>
- </tr>
- </table>
- <p>When these patterns are used in inclusion and exclusion, you have a powerful
- way to select just the files you want.</p>
- <h3>Examples</h3>
- <pre> <copydir srcdir="${src}"
- destdir="${dist}"
- includes="**/images/*"
- excludes="**/*.gif" /></pre>
- <p>This copies all files in directories called "images", that are
- located in the directory tree "${src}" to the destination "${dist}",
- but excludes all "*.gif" files from the copy.</p>
- <hr>
- <h2><a name="tasks">Built in tasks</a></h2>
- <ul>
- <li><a href="#ant">Ant</a></li>
- <li><a href="#chmod">Chmod</a></li>
- <li><a href="#copydir">Copydir</a></li>
- <li><a href="#copyfile">Copyfile</a></li>
- <li><a href="#cvs">Cvs</a></li>
- <li><a href="#delete">Delete</a></li>
- <li><a href="#deltree">Deltree</a></li>
- <li><a href="#echo">Echo</a></li>
- <li><a href="#exec">Exec</a></li>
- <li><a href="#expand">Expand</a></li>
- <li><a href="#get">Get</a></li>
- <li><a href="#gzip">GZip</a></li>
- <li><a href="#jar">Jar</a></li>
- <li><a href="#java">Java</a></li>
- <li><a href="#javac">Javac</a></li>
- <li><a href="#javadoc">Javadoc/Javadoc2</a></li>
- <li><a href="#keysubst">KeySubst</a></li>
- <li><a href="#mkdir">Mkdir</a></li>
- <li><a href="#property">Property</a></li>
- <li><a href="#replace">Replace</a></li>
- <li><a href="#rmic">Rmic</a></li>
- <li><a href="#taskdef">Taskdef</a></li>
- <li><a href="#tstamp">Tstamp</a></li>
- <li><a href="#zip">Zip</a></li>
- </ul>
- <hr>
- <h2><a name="ant">Ant</a></h2>
- <h3><b>Description:</b></h3>
- <p>Runs Ant on a supplied buildfile. This can be used to build subprojects.</p>
- <p>When the <i>antfile</i> attribute is omitted, the file "build.xml"
- in the supplied directory (<i>dir</i> attribute) is used.</p>
- <p>If no target attribute is supplied, the default target of the new project is
- used.</p>
- <p>The properties of the current project will be available in the new project.
- These properties will override the properties that are set in the new project.
- (See also the <a href="#property">properties task</a>).</p>
- <h3>Parameters:</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">antfile</td>
- <td valign="top">the buildfile to use.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">dir</td>
- <td valign="top">the directory to use as a basedir for the new Ant project.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">target</td>
- <td valign="top">the target of the new Ant project that should be executed.</td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <blockquote>
- <p><code><ant antfile="subproject/subbuild.xml" dir="subproject"
- target="compile" /></code></p>
- <p><code><ant dir="subproject" /></code></p>
- </blockquote>
- <hr>
- <h2><a name="chmod">Chmod</a></h2>
- <h3>Description</h3>
- <p>Changes the permissions of a file. Right now it has efect only under Unix.
- The permissions are also UNIX style, like the argument for the chmod command.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">src</td>
- <td valign="top">the file of which the permissions must be changed.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">perm</td>
- <td valign="top">the new permissions.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <blockquote>
- <p><code><chmod src="${dist}/start.sh" perm="ugo+rx"
- /></code></p>
- </blockquote>
- <p>makes the "start.sh" file readable and executable for anyone on a
- UNIX system.</p>
- <hr>
- <h2><a name="copydir">Copydir</a></h2>
- <h3>Description</h3>
- <p>Copies a directory tree from the source to the destination.</p>
- <p>It is possible to refine the set of files that are being copied. This can be
- done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
- attributes. With the <i>includes</i> attribute you specify the files you want to
- have included by using patterns. The <i>exclude</i> attribute is used to specify
- the files you want to have excluded. This is also done with patterns. And
- finally with the <i>defaultexcludes</i> attribute, you can specify whether you
- want to use default exclusions or not. See the section on <a
- href="#directorybasedtasks">directory based tasks</a>, on how the
- inclusion/exclusion of files works, and how to write patterns. The patterns are
- relative to the <i>src</i> directory.</p>
- <p>The <i>ignore</i> attribute contains the names of the files/directories that
- must be excluded from the copy. The names specified in the <i>ignore</i>
- attribute are just names, they do not contain any path information! Note that
- this attribute has been replaced by the <i>excludes</i> attribute.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">src</td>
- <td valign="top">the directory to copy.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">dest</td>
- <td valign="top">the directory to copy to.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">ignore</td>
- <td valign="top">comma separated list of filenames/directorynames to ignore.
- No files (except default excludes) are excluded when omitted. (<b>deprecated</b>,
- use <i>excludes</i> instead).</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">includes</td>
- <td valign="top">comma separated list of patterns of files that must be
- included. All files are included when omitted.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">excludes</td>
- <td valign="top">comma separated list of patterns of files that must be
- excluded. No files (except default excludes) are excluded when omitted.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">defaultexcludes</td>
- <td valign="top">indicates whether default excludes should be used or not
- ("yes"/"no"). Default excludes are used when omitted.</td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <copydir src="${src}/resources"
- dest="${dist}"
- /></pre>
- <p>copies the directory <code>${src}/resources</code> to <code>${dist}</code>.</p>
- <pre> <copydir src="${src}/resources"
- dest="${dist}"
- includes="**/*.java"
- excludes="**/Test.java"
- /></pre>
- <p>copies the directory <code>${src}/resources</code> to <code>${dist}</code>
- recursively. All java files are copied, except for files with the name <code>Test.java</code>.</p>
- <pre> <copydir src="${src}/resources"
- dest="${dist}"
- includes="**/*.java"
- excludes="mypackage/test/**" /></pre>
- <p>copies the directory <code>${src}/resources</code> to <code>${dist}</code>
- recursively. All java files are copied, except for the files under the <code>mypackage/test</code>
- directory.</p>
- <hr>
- <h2><a name="copyfile">Copyfile</a></h2>
- <h3>Description</h3>
- <p>Copies a file from the source to the destination. The file is only copied if
- the source file is newer than the destination file, or when the destination file
- does not exist.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">src</td>
- <td valign="top">the filename of the file to copy.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">dest</td>
- <td valign="top">the filename of the file where to copy to.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <blockquote>
- <p><code><copyfile src="test.java" dest="subdir/test.java"
- /></code></p>
- <p><code><copyfile src="${src}/index.html" dest="${dist}/help/index.html"
- /></code></p>
- </blockquote>
- <hr>
- <h2><a name="cvs">Cvs</a></h2>
- <h3>Description</h3>
- <p>Checks out a package/module from a <a href="http://www.cyclic.com/">CVS</a>
- repository.</p>
- <p>When doing automated builds, the <a href="#get">get task</a> should be
- preferred, because of speed.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">cvsRoot</td>
- <td valign="top">the CVSROOT variable.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">dest</td>
- <td valign="top">the directory where the checked out files should be placed.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">package</td>
- <td valign="top">the package/module to check out.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">tag</td>
- <td valign="top">the tag of the package/module to check out.</td>
- <td align="center" valign="top">No</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <cvs cvsRoot=":pserver:anoncvs@jakarta.apache.org:/home/cvspublic"
- package="jakarta-tools"
- dest="${ws.dir}"
- /></pre>
- <p>checks out the package/module "jakarta-tools" from the CVS
- repository pointed to by the cvsRoot attribute, and stores the files in "${ws.dir}".</p>
- <hr>
- <h2><a name="delete">Delete</a></h2>
- <h3>Description</h3>
- <p>Deletes a single file.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">file</td>
- <td valign="top">the file to delete.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <delete file="/lib/ant.jar" /></pre>
- <p>deletes the file <code>/lib/ant.jar</code>.</p>
- <pre> <delete file="${ant}" /></pre>
- <p>deletes the file <code>${ant}</code>.</p>
- <hr>
- <h2><a name="deltree">Deltree</a></h2>
- <h3>Description</h3>
- <p>Deletes a directory with all its files and subdirectories.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">dir</td>
- <td valign="top">the directory to delete.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <deltree dir="dist" /></pre>
- <p>deletes the directory <code>dist</code>, including its files and
- subdirectories.</p>
- <pre> <deltree dir="${dist}" /></pre>
- <p>deletes the directory <code>${dist}</code>, including its files and
- subdirectories.</p>
- <hr>
- <h2><a name="echo">Echo</a></h2>
- <h3>Description</h3>
- <p>Echoes a message to System.out.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">message</td>
- <td valign="top">the message to echo.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <echo message="Hello world" /></pre>
- <hr>
- <h2><a name="exec">Exec</a></h2>
- <h3>Description</h3>
- <p>Executes a system command. When the <i>os</i> attribute is specified, then
- the command is only executed when Ant is run on one of the specified operating
- systems.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">command</td>
- <td valign="top">the command to execute.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">dir</td>
- <td valign="top">the directory in which the command should be executed.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">os</td>
- <td valign="top">list of Operating Systems on which the command may be
- executed.</td>
- <td align="center" valign="top">No</td>
- </tr>
- <tr>
- <td valign="top">output</td>
- <td valign="top">the file to which the output of the command should be
- redirected.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <blockquote>
- <p><code><exec dir="${src}" command="dir" os="windows"
- output="dir.txt" /></code></p>
- </blockquote>
- <hr>
- <h2><a name="expand">Expand</a></h2>
- <h3>Description</h3>
- <p>Unzips a zipfile.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">src</td>
- <td valign="top">zipfile to expand.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">dest</td>
- <td valign="top">directory where to store the expanded files.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <blockquote>
- <p><code><expand src="${tomcat_src}/tools-src.zip" dest="${tools.home}"
- /></code></p>
- </blockquote>
- <hr>
- <h2><a name="get">Get</a></h2>
- <h3>Description</h3>
- <p>Gets a file from an URL. When the verbose option is "on", this task
- displays a '.' for every 100 Kb retrieved.</p>
- <p>This task should be preferred above the <a href="#cvs">CVS task</a> when
- doing automated builds. CVS is significant slower than loading a compressed
- archive with http/ftp.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">src</td>
- <td valign="top">the URL from which to retrieve a file.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">dest</td>
- <td valign="top">the file where to store the retrieved file.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">verbose</td>
- <td valign="top">show verbose information ("on"/"off").</td>
- <td align="center" valign="top">No</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <get src="http://jakarta.apache.org/" dest="help/index.html" /></pre>
- <p>gets the index page of http://jakarta.apache.org/, and stores it in the file <code>help/index.html</code>.</p>
- <hr>
- <h2><a name="gzip">GZip</a></h2>
- <h3>Description</h3>
- <p>GZips a file.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">src</td>
- <td valign="top">the file to gzip.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">zipfile</td>
- <td valign="top">the destination file.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <blockquote>
- <p><code><gzip src="test.tar" zipfile="test.tar.gz"
- /></code></p>
- </blockquote>
- <hr>
- <h2><a name="jar">Jar</a></h2>
- <h3>Description</h3>
- <p>Jars a set of files.</p>
- <p>The <i>basedir</i> attribute is the reference directory from where to jar.</p>
- <p>It is possible to refine the set of files that are being jarred. This can be
- done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
- attributes. With the <i>includes</i> attribute you specify the files you want to
- have included by using patterns. The <i>exclude</i> attribute is used to specify
- the files you want to have excluded. This is also done with patterns. And
- finally with the <i>defaultexcludes</i> attribute, you can specify whether you
- want to use default exclusions or not. See the section on <a
- href="#directorybasedtasks">directory based tasks</a>, on how the
- inclusion/exclusion of files works, and how to write patterns. The patterns are
- relative to the <i>basedir</i> directory.</p>
- <p>The <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i> attributes
- replace the <i>items</i> and <i>ignore</i> attributes. The following explains
- how the deprecated <i>items</i> and <i>ignore</i> attribute behave.</p>
- <p>When "*" is used for <i>items</i>, all files in the basedir, and
- its subdirectories, will be jarred. Otherwise all the files and directories
- mentioned in the items list will jarred. When a directory is specified, then all
- files within it are also jarred.</p>
- <p>With the <i>ignore</i> attribute, you can specify files or directories to
- ignore. These files will not be jarred. The items in the <i>ignore</i> attribute
- override the items in the <i>items</i> attribute. The names specified in the <i>ignore</i>
- attribute are just names, they do not contain any path information!</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">jarfile</td>
- <td valign="top">the jar-file to create.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">basedir</td>
- <td valign="top">the directory from which to jar the files.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">items</td>
- <td valign="top">a comma separated list of the files/directories to jar. All
- files are included when omitted. (<b>deprecated</b>, use <i>includes</i>
- instead).</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">ignore</td>
- <td valign="top">comma separated list of filenames/directorynames to exclude
- from the jar. No files (except default excludes) are excluded when
- omitted. (<b>deprecated</b>, use <i>excludes</i> instead).</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">includes</td>
- <td valign="top">comma separated list of patterns of files that must be
- included. All files are included when omitted.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">excludes</td>
- <td valign="top">comma separated list of patterns of files that must be
- excluded. No files (except default excludes) are excluded when omitted.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">defaultexcludes</td>
- <td valign="top">indicates whether default excludes should be used or not
- ("yes"/"no"). Default excludes are used when omitted.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">manifest</td>
- <td valign="top">the manifest file to use.</td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <jar jarfile="${dist}/lib/app.jar" basedir="${build}/classes" /></pre>
- <p>jars all files in the <code>${build}/classes</code> directory in a file
- called <code>app.jar</code> in the <code>${dist}/lib</code> directory.</p>
- <pre> <jar jarfile="${dist}/lib/app.jar"
- basedir="${build}/classes"
- excludes="**/Test.class"
- /></pre>
- <p>jars all files in the <code>${build}/classes</code> directory in a file
- called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Files
- with the name <code>Test.class</code> are excluded.</p>
- <pre> <jar jarfile="${dist}/lib/app.jar"
- basedir="${build}/classes"
- includes="mypackage/test/**"
- excludes="**/Test.class"
- /></pre>
- <p>jars all files in the <code>${build}/classes</code> directory in a file
- called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Only
- files under the directory <code>mypackage/test</code> are used, and files with
- the name <code>Test.class</code> are excluded.</p>
- <h3>Deprecated examples</h3>
- <pre> <jar jarfile="${dist}/lib/app.jar" basedir="${build}/classes" items="*" /></pre>
- <p>jars all files in the <code>${build}/classes</code> directory in a file
- called <code>app.jar</code> in the <code>${dist}/lib</code> directory.</p>
- <pre> <jar jarfile="${dist}/lib/app.jar" basedir="${build}/classes" items="*" ignore="Test.class" /></pre>
- <p>jars all files in the <code>${build}/classes</code> directory in a file
- called <code>app.jar</code> in the <code>${dist}/lib</code> directory.
- Files/directories with the name <code>Test.class</code> are excluded.</p>
- <hr>
- <h2><a name="java">Java</a></h2>
- <h3>Description</h3>
- <p>Executes a Java class within the running (Ant) VM or forks another VM if
- specified.</p>
- <p>Be careful that the executed class doesn't call System.exit(), because it
- will terminate the VM and thus Ant. In case this happens, it's highly suggested
- that you set the fork attribute so that System.exit() stops the other VM and not
- the one that is currently running Ant.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">class</td>
- <td valign="top">the Java class to execute.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">args</td>
- <td valign="top">the arguments for the class that is executed.</td>
- <td align="center" valign="top">No</td>
- </tr>
- <tr>
- <td valign="top">fork</td>
- <td valign="top">if enabled triggers the class execution in another VM
- (disabled by default)</td>
- <td align="center" valign="top">No</td>
- </tr>
- <tr>
- <td valign="top">jvmargs</td>
- <td valign="top">the arguments to pass to the forked VM (ignored if fork is
- disabled)</td>
- <td align="center" valign="top">No</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <java class="test.Main" /></pre>
- <pre> <java class="test.Main" args="-h" /></pre>
- <pre> <java class="test.Main"
- args="-h"
- fork="yes"
- jvmargs="-Xrunhprof:cpu=samples,file=log.txt,depth=3"
- /></pre>
- <hr>
- <h2><a name="javac">Javac</a></h2>
- <h3>Description</h3>
- <p>Compiles a source tree within the running (Ant) VM.</p>
- <p>The source and destination directory will be recursively scanned for Java
- source files to compile. Only Java files that have no corresponding class file
- or where the class file is older than the java file will be compiled.</p>
- <p>Files in the source tree, that are no java files, are copied to the
- destination directory, allowing support files to be located properly in the
- classpath.</p>
- <p>The directory structure of the source tree should follow the package
- hierarchy.</p>
- <p>It is possible to refine the set of files that are being compiled/copied.
- This can be done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
- attributes. With the <i>includes</i> attribute you specify the files you want to
- have included by using patterns. The <i>exclude</i> attribute is used to specify
- the files you want to have excluded. This is also done with patterns. And
- finally with the <i>defaultexcludes</i> attribute, you can specify whether you
- want to use default exclusions or not. See the section on <a
- href="#directorybasedtasks">directory based tasks</a>, on how the
- inclusion/exclusion of files works, and how to write patterns. The patterns are
- relative to the <i>srcdir</i> directory.</p>
- <p>It is possible to use different compilers. This can be selected with the
- "build.compiler" property. There are three choices:</p>
- <ul>
- <li>classic (the standard compiler of JDK 1.1/1.2)</li>
- <li>modern (the new compiler of JDK 1.3)</li>
- <li>jikes (the <a
- href="http://oss.software.ibm.com/developerworks/opensource/jikes/project">Jikes</a>
- compiler)</li>
- </ul>
- <p>For JDK 1.1/1.2 is classic the default. For JDK 1.3 is modern the default.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">srcdir</td>
- <td valign="top">location of the java files.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">destdir</td>
- <td valign="top">location where to store the class files.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">includes</td>
- <td valign="top">comma separated list of patterns of files that must be
- included. All files are included when omitted.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">excludes</td>
- <td valign="top">comma separated list of patterns of files that must be
- excluded. No files (except default excludes) are excluded when omitted.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">defaultexcludes</td>
- <td valign="top">indicates whether default excludes should be used or not
- ("yes"/"no"). Default excludes are used when omitted.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">classpath</td>
- <td valign="top">the classpath to use.</td>
- <td align="center" valign="top">No</td>
- </tr>
- <tr>
- <td valign="top">bootclasspath</td>
- <td valign="top">location of bootstrap class files.</td>
- <td align="center" valign="top">No</td>
- </tr>
- <tr>
- <td valign="top">extdirs</td>
- <td valign="top">location of installed extensions.</td>
- <td align="center" valign="top">No</td>
- </tr>
- <tr>
- <td valign="top">debug</td>
- <td valign="top">indicates whether there should be compiled with debug
- information ("on").</td>
- <td align="center" valign="top">No</td>
- </tr>
- <tr>
- <td valign="top">optimize</td>
- <td valign="top">indicates whether there should be compiled with
- optimization ("on").</td>
- <td align="center" valign="top">No</td>
- </tr>
- <tr>
- <td valign="top">deprecation</td>
- <td valign="top">indicates whether there should be compiled with deprecation
- information ("on").</td>
- <td align="center" valign="top">No</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <javac srcdir="${src}"
- destdir="${build}"
- classpath="xyz.jar"
- debug="on"
- /></pre>
- <p>compiles all .java files under the directory <code>${src}</code>, and stores
- the .class files in the directory <code>${build}</code>. It also copies the non-java
- files from the tree under <code>${src}</code> to the tree under <code>${build}</code>.
- The classpath used contains <code>xyz.jar</code>, and debug information is on.</p>
- <pre> <javac srcdir="${src}"
- destdir="${build}"
- includes="mypackage/p1/**,mypackage/p2/**"
- excludes="mypackage/p1/testpackage/**"
- classpath="xyz.jar"
- debug="on"
- /></pre>
- <p>compiles .java files under the directory <code>${src}</code>, and stores the
- .class files in the directory <code>${build}</code>. It also copies the non-java
- files from the tree under <code>${src}</code> to the tree under <code>${build}</code>.
- The classpath used contains <code>xyz.jar</code>, and debug information is on.
- Only files under <code>mypackage/p1</code> and <code>mypackage/p2</code> are
- used. Files in the <code>mypackage/p1/testpackage</code> directory are excluded
- form compilation and copy.</p>
- <hr>
- <h2><a name="javadoc">Javadoc/Javadoc2</a></h2>
- <h3>Description</h3>
- <p>Generates code documentation using the javadoc tool.</p>
- <p>The source directory will be recursively scanned for Java source files to but
- only those matching the inclusion rules will be passed to the javadoc tool. This
- allows wildcards to be used to choose between package names, reducing verbosity
- and management costs over time. This task, however, has no notion of
- "changed" files, unlike the <a href="#javac">javac</a> task, but it's
- not used so frequently.</p>
- <p>This task works seamlessly between different javadoc versions (1.1 and 1.2),
- with the obvious restriction that the 1.2 attributes will be ignored if run in a
- 1.1 VM.</p>
- <p>NOTE: since javadoc calls System.exit(), we cannot run javadoc inside the
- same VM without breaking functionality. For this reason, this task always forks
- the VM. But this is not a performance penalty since javadoc is normally a heavy
- application and must be called just once.</p>
- <p>DEPRECATION: the javadoc2 task simply points to the javadoc task and it's
- there for back compatibility reasons. Since this task will be removed in future
- versions, you are strongly encouraged to use <a href="#javadoc">javadoc</a>
- instead.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Availability</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">sourcepath</td>
- <td valign="top">Specify where to find source files</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="top">yes</td>
- </tr>
- <tr>
- <td valign="top">destdir</td>
- <td valign="top">Destination directory for output files</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="top">yes</td>
- </tr>
- <tr>
- <td valign="top">sourcefiles</td>
- <td valign="top">Space separated list of source files</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="middle" rowspan="2">at least one of the two</td>
- </tr>
- <tr>
- <td valign="top">packagenames</td>
- <td valign="top">Space separated list of package files (with terminating
- wildcard)</td>
- <td align="center" valign="top">all</td>
- </tr>
- <tr>
- <td valign="top">Classpath</td>
- <td valign="top">Specify where to find user class files</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Bootclasspath</td>
- <td valign="top">Override location of class files loaded by the bootstrap
- class loader</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Extdirs</td>
- <td valign="top">Override location of installed extensions</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Overview</td>
- <td valign="top">Read overview documentation from HTML file</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Public</td>
- <td valign="top">Show only public classes and members</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Protected</td>
- <td valign="top">Show protected/public classes and members (default)</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Package</td>
- <td valign="top">Show package/protected/public classes and members</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Private</td>
- <td valign="top">Show all classes and members</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Old</td>
- <td valign="top">Generate output using JDK 1.1 emulating doclet</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Verbose</td>
- <td valign="top">Output messages about what Javadoc is doing</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Locale</td>
- <td valign="top">Locale to be used, e.g. en_US or en_US_WIN</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Encoding</td>
- <td valign="top">Source file encoding name</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Version</td>
- <td valign="top">Include @version paragraphs</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Use</td>
- <td valign="top">Create class and package usage pages</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Author</td>
- <td valign="top">Include @author paragraphs</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Splitindex</td>
- <td valign="top">Split index into one file per letter</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Windowtitle</td>
- <td valign="top">Browser window title for the documenation (text)</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Doctitle</td>
- <td valign="top">Include title for the package index(first) page (html-code)</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Header</td>
- <td valign="top">Include header text for each page (html-code)</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">Footer</td>
- <td valign="top">Include footer text for each page (html-code)</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">bottom</td>
- <td valign="top">Include bottom text for each page (html-code)</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">link</td>
- <td valign="top">Create links to javadoc output at the given URL</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">linkoffline</td>
- <td valign="top">Link to docs at <url> using package list at
- <url2></td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">group</td>
- <td valign="top">Group specified packages together in overview page</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">nodeprecated</td>
- <td valign="top">Do not include @deprecated information</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">nodeprecatedlist</td>
- <td valign="top">Do not generate deprecated list</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">notree</td>
- <td valign="top">Do not generate class hierarchy</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">noindex</td>
- <td valign="top">Do not generate index</td>
- <td align="center" valign="top">all</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">nohelp</td>
- <td valign="top">Do not generate help link</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">nonavbar</td>
- <td valign="top">Do not generate navigation bar</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">serialwarn</td>
- <td valign="top">Generate warning about @serial tag</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">helpfile</td>
- <td valign="top">Specifies the HTML help file to use</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">stylesheetfile</td>
- <td valign="top">Specifies the CSS stylesheet to use</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">charset</td>
- <td valign="top">Charset for cross-platform viewing of generated
- documentation</td>
- <td align="center" valign="top">1.2</td>
- <td align="center" valign="top">no</td>
- </tr>
- <tr>
- <td valign="top">docencoding</td>
- <td valign="top">Output file encoding name</td>
- <td align="center" valign="top">1.1</td>
- <td align="center" valign="top">no</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <javadoc packagenames="com.dummy.test.*"
- sourcepath="src"
- destdir="docs/api"
- author="true"
- version="true"
- use="true"
- windowtitle="Test API"
- doctitle="<h1>Test</h1>"
- bottom="<i>Copyright &#169; 2000 Dummy Corp. All Rights Reserved.</i>"
- /></pre>
- <hr>
- <h2><a name="keysubst">KeySubst</a></h2>
- <h3>Description</h3>
- <p>Performs keyword substitution in the source file, and writes the result to
- the destination file.</p>
- <p>Keys in the source file are of the form ${keyname}. The <i>keys</i> attribute
- contains key/value pairs. When a key is found in the <i>keys</i> attribute, then
- "${keyname}" is replaced by the corresponding value.</p>
- <p>The <i>keys</i> attribute is of the form
- "name1=value1*name2=value2*name3=value3". The '*' is called the
- separator, which might we changed with the <i>sep</i> attribute.</p>
- <p>Note: the source file and destination file may not be the same.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">src</td>
- <td valign="top">the source file.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">dest</td>
- <td valign="top">the destination file.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">sep</td>
- <td valign="top">the separator for the name/value pairs.</td>
- <td align="center" valign="top">No</td>
- </tr>
- <tr>
- <td valign="top">keys</td>
- <td valign="top">name/value pairs for replacement.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <keysubst src="abc.txt" dest="def.txt" keys="VERSION=1.0.3*DATE=2000-01-10" /></pre>
- <hr>
- <h2><a name="mkdir">Mkdir</a></h2>
- <h3>Description</h3>
- <p>Creates a directory. Also non-existent parent directories are created, when
- necessary.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">dir</td>
- <td valign="top">the directory to create.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre><mkdir dir="${dist}" /></pre>
- <p>creates a directory <code>${dist}</code>.</p>
- <pre><mkdir dir="${dist}/lib" /></pre>
- <p>creates a directory <code>${dist}/lib</code>.</p>
- <hr>
- <h2><a name="property">Property</a></h2>
- <h3>Description</h3>
- <p>Sets a property (by name and value), or set of properties (from file or
- resource) in the project.</p>
- <p>When a property was set by the user, or was a property in a parent project
- (that started this project with the <a href="#ant">ant task</a>), then this
- property cannot be set, and will be ignored. This means that properties set
- outside the current project always override the properties of the current
- project.</p>
- <p>There are three ways to set properties:</p>
- <ul>
- <li>By supplying both the <i>name</i> and <i>value</i> attribute.</li>
- <li>By setting the <i>file</i> attribute with the filename of the property
- file to load. This property file has the format as defined by the file used
- in the class java.util.Properties.</li>
- <li>By setting the <i>resource</i> attribute with the resource name of the
- property file to load. This property file has the format as defined by the
- file used in the class java.util.Properties.</li>
- </ul>
- <p>Although combinations of the three ways are possible, only one should be used
- at a time. Problems might occur with the order in which properties are set, for
- instance.</p>
- <p>The value part of the properties being set, might contain references to other
- properties. These references are resolved at the time these properties are set.
- This also holds for properties loaded from a property file.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">name</td>
- <td valign="top">the name of the property to set.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">value</td>
- <td valign="top">the value of the property.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">resource</td>
- <td valign="top">the resource name of the property file.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">file</td>
- <td valign="top">the filename of the property file .</td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <property name="foo.dist" value="dist" /></pre>
- <p>sets the property <code>foo.dist</code> to the value "dist".</p>
- <pre> <property file="foo.properties" /></pre>
- <p>reads a set of properties from a file called "foo.properties".</p>
- <pre> <property resource="foo.properties" /></pre>
- <p>reads a set of properties from a resource called "foo.properties".</p>
- <hr>
- <h2><a name="replace">Replace</a></h2>
- <h3>Description</h3>
- <p>Replaces the occurrence of a given string with another string in a file.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">file</td>
- <td valign="top">file for which the token should be replaced.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">token</td>
- <td valign="top">the token which must be replaced.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">value</td>
- <td valign="top">the new value for the token. When omitted, an empty string
- ("") is used.</td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <replace file="${src}/index.html" token="@@@" value="wombat" /></pre>
- <p>replaces occurrences of the string "@@@" with the string
- "wombat", in the file <code>${src}/index.html</code>.</p>
- <hr>
- <h2><a name="rmic">Rmic</a></h2>
- <h3>Description</h3>
- <p>Runs the rmic compiler for a certain class.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">base</td>
- <td valign="top">the location to store the compiled files.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">class</td>
- <td valign="top">the class for which to run <code>rmic</code>.</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <rmic class="com.xyz.FooBar" base="${build}/classes" /></pre>
- <p>runs the rmic compiler for the class <code>com.xyz.FooBar</code>. The
- compiled files will be stored in the directory <code>${build}/classes</code>.</p>
- <hr>
- <h2><a name="taskdef">Taskdef</a></h2>
- <h3>Description</h3>
- <p>Adds a task definition to the current project, such that this new task can be
- used in the current project. Two attributes are needed, the name that identifies
- this task uniquely, and the full name of the class (including the packages) that
- implements this task.</p>
- <p>Taskdef should be used to add your own tasks to the system. See also "<a
- href="#writingowntask">Writing your own task</a>".</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">name</td>
- <td valign="top">the name of the task</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- <tr>
- <td valign="top">class</td>
- <td valign="top">the full class name implementing the task</td>
- <td valign="top" align="center">Yes</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <taskdef name="myjavadoc" value="com.mydomain.JavadocTask" /></pre>
- <p>makes a task called <code>myjavadoc</code> available to Ant. The class <code>com.mydomain.JavadocTask</code>
- implements the task.</p>
- <hr>
- <h2><a name="tstamp">Tstamp</a></h2>
- <h3>Description</h3>
- <p>Sets the DSTAMP, TSTAMP and TODAY properties in the current project. The
- DSTAMP is in the "yyyymmdd" format, the TSTAMP is in the "hhmm"
- format and TODAY is "month day year".</p>
- <p>These properties can be used in the buildfile, for instance, to create
- timestamped filenames or used to replace placeholder tags inside documents to
- indicate, for example, the release date. The best place for this task is in the <a
- href="#inittarget">init target</a>.</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td align="center" valign="top"><b>Required</b></td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <tstamp/></pre>
- <hr>
- <h2><a name="zip">Zip</a></h2>
- <h3>Description</h3>
- <p>Creates a zipfile.</p>
- <p>The <i>basedir</i> attribute is the reference directory from where to zip.</p>
- <p>It is possible to refine the set of files that are being zipped. This can be
- done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
- attributes. With the <i>includes</i> attribute you specify the files you want to
- have included by using patterns. The <i>exclude</i> attribute is used to specify
- the files you want to have excluded. This is also done with patterns. And
- finally with the <i>defaultexcludes</i> attribute, you can specify whether you
- want to use default exclusions or not. See the section on <a
- href="#directorybasedtasks">directory based tasks</a>, on how the
- inclusion/exclusion of files works, and how to write patterns. The patterns are
- relative to the <i>basedir</i> directory.</p>
- <p>The <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i> attributes
- replace the <i>items</i> and <i>ignore</i> attributes. The following explains
- how the deprecated <i>items</i> and <i>ignore</i> attribute behave.</p>
- <p>When "*" is used for <i>items</i>, all files in the basedir, and
- its subdirectories, will be zipped. Otherwise all the files and directories
- mentioned in the items list will zipped. When a directory is specified, then all
- files within it are also zipped.</p>
- <p>With the <i>ignore</i> attribute, you can specify files or directories to
- ignore. These files will not be zipped. The items in the <i>ignore</i> attribute
- override the items in the <i>items</i> attribute. The names specified in the <i>ignore</i>
- attribute are just names, they do not contain any path information!</p>
- <h3>Parameters</h3>
- <table border="1" cellpadding="2" cellspacing="0">
- <tr>
- <td valign="top"><b>Attribute</b></td>
- <td valign="top"><b>Description</b></td>
- <td valign="top" align="center"><b>Required</b></td>
- </tr>
- <tr>
- <td valign="top">zipfile</td>
- <td valign="top">the zip-file to create.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">basedir</td>
- <td valign="top">the directory from which to zip the files.</td>
- <td align="center" valign="top">Yes</td>
- </tr>
- <tr>
- <td valign="top">items</td>
- <td valign="top">a comma separated list of the files/directories to zip. All
- files are included when omitted. (<b>deprecated</b>, use <i>includes</i>
- instead).</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">ignore</td>
- <td valign="top">comma separated list of filenames/directorynames to exclude
- from the zip. No files (except default excludes) are excluded when
- omitted. (<b>deprecated</b>, use <i>excludes</i> instead).</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">includes</td>
- <td valign="top">comma separated list of patterns of files that must be
- included. All files are included when omitted.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">excludes</td>
- <td valign="top">comma separated list of patterns of files that must be
- excluded. No files (except default excludes) are excluded when omitted.</td>
- <td valign="top" align="center">No</td>
- </tr>
- <tr>
- <td valign="top">defaultexcludes</td>
- <td valign="top">indicates whether default excludes should be used or not
- ("yes"/"no"). Default excludes are used when omitted.</td>
- <td valign="top" align="center">No</td>
- </tr>
- </table>
- <h3>Examples</h3>
- <pre> <zip zipfile="${dist}/manual.zip"
- basedir="htdocs/manual"
- /></pre>
- <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
- in the <code>${dist}</code> directory.</p>
- <pre> <zip zipfile="${dist}/manual.zip"
- basedir="htdocs/manual"
- excludes="mydocs/**, **/todo.html"
- /></pre>
- <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
- in the <code>${dist}</code> directory. Files in the directory <code>mydocs</code>,
- or files with the name <code>todo.html</code> are excluded.</p>
- <pre> <zip zipfile="${dist}/manual.zip"
- basedir="htdocs/manual"
- includes="api/**/*.html"
- excludes="**/todo.html"
- /></pre>
- <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
- in the <code>${dist}</code> directory. Only html files under the directory <code>api</code>
- are zipped, and files with the name <code>todo.html</code> are excluded.</p>
- <h3>Deprecated examples</h3>
- <pre> <zip zipfile="${dist}/manual.zip"
- basedir="htdocs/manual"
- items="*"
- /></pre>
- <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
- in the <code>${dist}</code> directory.</p>
- <pre> <zip zipfile="${dist}/manual.zip"
- basedir="htdocs/manual"
- items="*"
- ignore="mydocs, todo.html"
- /></pre>
- <p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code>
- in the <code>${dist}</code> directory. Files/directories with the names <code>mydocs</code>
- and <code>todo.html</code> are excluded.</p>
- <hr>
- <h2><a name="writingowntask">Writing your own task</a></h2>
- <p>It is very easy to write your own task:</p>
- <ol>
- <li>Create a Java class that extends <code>org.apache.tools.ant.Task</code>.</li>
- <li>For each attribute, write a setter method. The setter method must be a <code>public
- void</code> method that takes one <code>String</code> as an argument. The
- name of the method must begin with "set", followed by the
- attribute name, with the first character in uppercase, and the rest in
- lowercase.</li>
- <li>Write a <code>public void execute</code> method, with no arguments, that
- throws a <code>BuildException</code>. This method implements the task
- itself.</li>
- </ol>
- <p>It is important to know that Ant first calls the setters for the attributes
- it encounters for a specific task in the buildfile, before it executes is.</p>
- <p>Let's write our own task, that prints a message on the System.out stream. The
- task has one attribute called "message".</p>
- <blockquote>
- <pre>public class MyVeryOwnTask extends Task {
- private String msg;
-
- // The method executing the task
- public void execute() throws BuildException {
- System.out.println(message);
- }
-
- // The setter for the "message" attribute
- public void setMessage(String msg) {
- this.msg = msg;
- }
- }</pre>
- </blockquote>
- <p>It's really this simple;-)</p>
- <p>Adding your task to the system is rather simple too:</p>
- <ol>
- <li>Make sure the class that implements your task is in the classpath when
- starting Ant.</li>
- <li>In the <i>init</i> target, add a <i>taskdef</i> task. This actually adds
- your task to the system.</li>
- <li>Use your task in the rest of the buildfile.</li>
- </ol>
- <h3>Example</h3>
- <blockquote>
- <pre><project name="TaskTest" default="test" basedir=".">
- <target name="init">
- <taskdef name="mytask" class="com.mydomain.MyVeryOwnTask"/>
- </target>
-
- <target name="test">
- <mytask myattr="wombat" />
- </target>
- </project>
- </pre>
- </blockquote>
- <p>Another way to add a task (more permanently), is to add the task name and
- implementing class name to the <code>default.properties</code> file in the <code>org.apache.tools.ant.taskdefs</code>
- package. Then you can use it as if it were a built in task.</p>
- <hr>
- <h2><a name="feedback">Feedback</a></h2>
- <p>To provide feedback on this software, please subscribe to the Ant Development
- Mail List <a href="mailto:(ant-dev-subscribe@jakarta.apache.org">(ant-dev-subscribe@jakarta.apache.org</a>)</p>
- <hr>
- <p align="center">Copyright 2000 Apache Software Foundation. All rights
- Reserved.</p>
-
- </body>
-
- </html>
|