of Ant (as verified with <tt>ant -version</tt>) is older or newer than this
version then this is not the correct manual set. Please use the documentation
appropriate to your current version. Also, if you are using a version
older than the most recent release, we recommend an upgrade to fix bugs
as well as provide new functionality. </p>
<p> </p>
<p align="left">Ant's manual and API documentation is part of
the <a href="http://ant.apache.org/bindownload.cgi">binary</a>
@@ -48,6 +47,5 @@
<p>Apache Ant, Apache Ivy, Ant, Ivy, Apache, the Apache feather logo, and the Apache Ant project logos are trademarks of The Apache Software Foundation.</p>
We get lots of support calls from Cygwin users. Either it is incredibly
popular, or it is trouble. If you do use it, remember that Java is a
Windows application, so Ant is running in a Windows process, not a
Cygwin one. This will save us having to mark your bug reports as invalid.
Cygwin one. This will save us having to mark your bug reports as invalid.
</p>
<h2>Apple MacOS X</h2>
<p>
MacOS X is the first of the Apple platforms that Ant supports completely;
it is treated like any other Unix.
it is treated like any other Unix.
</p>
<h2>Novell Netware</h2>
<p>To give the same level of sophisticated control as Ant's startup scripts on other platforms, it was decided to make the main ant startup on NetWare be via a Perl Script, "runant.pl". This is found in the bin directory (for instance - bootstrap\bin or dist\bin).</p>
<p>One important item of note is that you need to set up the following to run ant:</p>
<p>One important item of note is that you need to set up the following to run Ant:</p>
<ul><li><code>CLASSPATH</code> - put ant.jar and any other needed jars on the system classpath.</li>
<li><code>ANT_OPTS</code> - On NetWare, <code>ANT_OPTS</code> needs to include a parameter of the form, <nobr>"-envCWD=<code>ANT_HOME</code>"</nobr>, with <code>ANT_HOME</code> being the fully expanded location of Ant, <b>not</b> an environment variable. This is due to the fact that the NetWare System Console has no notion of a current working directory.</li>
<li><code>ANT_OPTS</code> - On NetWare, <code>ANT_OPTS</code> needs to include a parameter of the form, "<code>-envCWD=<i>ANT_HOME</i></code>", with <code><i>ANT_HOME</i></code> being the fully expanded location of Ant, <b>not</b> an environment variable. This is due to the fact that the NetWare System Console has no notion of a current working directory.</li>
</ul>
<p>It is suggested that you create up an ant.ncf that sets up these parameters, and calls <code>perl ANT_HOME/dist/bin/runant.pl</code></p>
<p>The following is an example of such an NCF file(assuming ant is installed in <nobr>'sys:/apache-ant/'):</nobr></p>
<p>Ant works on JVM version 1.3 or higher. You may have some luck running it on JVM 1.2, but serious problems have been found running Ant on JVM 1.1.7B. These problems are caused by JVM bugs that will not be fixed.</p>
<p>JVM 1.3 is supported on Novell NetWare versions 5.1 and higher.</p>
<h2>Other platforms</h2>
Support for other platforms is not guaranteed to be complete, as certain
Support for other platforms is not guaranteed to be complete, as certain
techniques to hide platform details from build files need to be written and
tested on every particular platform. Contributions in this area are welcome.
<a href="listeners.html">Loggers & Listeners</a>.
<p>For more information about <code>-inputhandler</code> see
<a href="inputhandler.html">InputHandler</a>.
<p>Easiest way of changing the exit-behaviour is subclassing the original main class:
<p>Easiest way of changing the exit-behaviour is subclassing the original main class:</p>
<pre>
public class CustomExitCode extends org.apache.tools.ant.Main {
protected void exit(int exitCode) {
// implement your own behaviour, e.g. NOT exiting the JVM
}
}
</pre> and starting Ant with access (<tt>-lib path-to-class</tt>) to this class.
</p>
</pre>
<p>and starting Ant with access (<tt>-lib path-to-class</tt>) to this class.</p>
<h3><a name="libs">Library Directories</a></h3>
<h3 id="libs">Library Directories</h3>
<p>
Prior to Ant 1.6, all jars in the ANT_HOME/lib would be added to the CLASSPATH
used to run Ant. This was done in the scripts that started Ant. From Ant 1.6,
used to run Ant. This was done in the scripts that started Ant. <em>Since Ant 1.6</em>,
two directories are scanned by default and more can be added as required. The
default directories scanned are ANT_HOME/lib and a user specific directory,
${user.home}/.ant/lib. This arrangement allows the Ant installation to be
@@ -180,7 +180,6 @@ option. Ant itself is started with a very minimalistic classpath.
Ant should work perfectly well with an empty CLASSPATH environment variable,
something the the -noclasspath option actually enforces. We get many more support calls related to classpath problems (especially quoting problems) than
we like.
</p>
<p>
@@ -229,9 +228,7 @@ to the value <code>build/classes</code>.</p>
</blockquote>
<p>adds two jars to Ants classpath.</p>
<h3><a name="files">Files</a></h3>
<h3 id="files">Files</h3>
<p>The Ant wrapper script for Unix will source (read and evaluate) the
file <code>~/.antrc</code> before it does anything. On Windows, the Ant
@@ -240,7 +237,7 @@ wrapper batch-file invokes <code>%HOME%\antrc_pre.bat</code> at the start and
files, for example, to set/unset environment variables that should only be
visible during the execution of Ant. See the next section for examples.</p>
<h2 id="TaskAdapter">Integration with TaskAdapter</h2>
<p>Our class has nothing to do with Ant. It extends no superclass and implements
no interface. How does Ant know to integrate? Via name convention: our class provides
a method with signature <tt>public void execute()</tt>. This class is wrapped by Ant's
@@ -202,9 +193,7 @@ use:
Here is project 'MyTask'.
</pre>
<a name="derivingFromTask"></a>
<h2>Deriving from Ant's Task</h2>
<h2 id="derivingFromTask">Deriving from Ant's Task</h2>
<p>Ok, that works ... But usually you will extend <tt>org.apache.tools.ant.Task</tt>.
That class is integrated in Ant, get's the project-reference, provides documentation
fields, provides easier access to the logging facility and (very useful) gives you
@@ -234,8 +223,7 @@ use:
[helloworld] I am used in: C:\tmp\anttests\MyFirstTask\build.xml:23:
</pre>
<a name="accessTaskProject"></a>
<h2>Accessing the Task's Project</h2>
<h2 id="accessTaskProject">Accessing the Task's Project</h2>
<p>The parent project of your custom task may be accessed through method <code>getProject()</code>. However, do not call this from the custom task constructor, as the return value will be null. Later, when node attributes or text are set, or method <code>execute()</code> is called, the Project object is available.</p>
<p>Here are two useful methods from class Project:</p>
<ul>
@@ -247,8 +235,7 @@ use:
<p>The method <code>replaceProperties()</code> is discussed further in section <a href="#NestedText">Nested Text</a>.</p>
<a name="attributes"></a>
<h2>Attributes</h2>
<h2 id="attributes">Attributes</h2>
<p>Now we want to specify the text of our message (it seems that we are
rewriting the <code><echo/></code> task :-). First we well do that with an attribute.
It is very easy - for each attribute provide a <tt>public void set<code><attributename></code>(<code><type></code>
@@ -304,9 +291,7 @@ Helper</a></li>
Before calling the set-method all properties are resolved. So a <tt><helloworld message="${msg}"/></tt>
would not set the message string to "${msg}" if there is a property "msg" with a set value.
<a name="NestedText"></a>
<h2>Nested Text</h2>
<h2 id="NestedText">Nested Text</h2>
<p>Maybe you have used the <code><echo></code> task in a way like <tt><echo>Hello World</echo></tt>.
For that you have to provide a <tt>public void addText(String text)</tt> method.</p>
<pre class="code">
@@ -330,9 +315,7 @@ property name as argument and returns its value (or ${propname} if not set).</p>
}
</pre>
<a name="NestedElements"></a>
<h2>Nested Elements</h2>
<h2 id="NestedElements">Nested Elements</h2>
<p>There are several ways for inserting the ability of handling nested elements. See
the <a href="http://ant.apache.org/manual/develop.html#nested-elements">Manual [4]</a> for other.
We use the first way of the three described ways. There are several steps for that:</p><ol>
@@ -387,8 +370,7 @@ the buildfile</p>
<p>Note that if you choose to use methods 2 or 3, the class that represents the nested
element must be declared as <code>static</code></p>
<a name="complex"></a>
<h2>Our task in a little more complex version</h2>
<h2 id="complex">Our task in a little more complex version</h2>
<p>For recapitulation now a little refactored buildfile:</p>
<p>We have written a test already: the use.* tasks in the buildfile. But its
difficult to test that automatically. Common (and in Ant) used is JUnit for
that. For testing tasks Ant provides a JUnit Rule <tt>org.apache.tools.ant.BuildFileRule</tt>.
@@ -771,9 +750,7 @@ Total time: 7 seconds
C:\tmp\anttests\MyFirstTask>
</pre>
<a name="Debugging"></a>
<h2>Debugging</h2>
<h2 id="Debugging">Debugging</h2>
<p>Try running Ant with the flag <code>-verbose</code>. For more information, try flag <code>-debug</code>.</p>
<p>For deeper issues, you may need to run the custom task code in a Java debugger. First, get the source for Ant and build it with debugging information.</p>
<p>If you need to debug when a task attribute or the text is set, begin by debugging into method <code>execute()</code> of your custom task. Then set breakpoints in other methods. This will ensure the class byte-code has been loaded by the Java VM.</p>
<a name="resources"></a>
<h2>Resources</h2>
<h2 id="resources">Resources</h2>
<p>This tutorial and its resources are available via
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.