2001-04-10 07:06:37 +00:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Language" content="en-us">
|
2002-02-04 20:57:49 +00:00
|
|
|
<title>Running Apache Ant</title>
|
2001-04-10 07:06:37 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h1>Running Ant</h1>
|
2001-12-13 17:16:26 +00:00
|
|
|
<h2><a name="commandline">Command Line</a></h2>
|
|
|
|
<p> If you've installed Ant as described in the
|
|
|
|
<a href="install.html"> Installing Ant</a> section,
|
|
|
|
running Ant from the command-line is simple: just type
|
|
|
|
<code>ant</code>.</p>
|
|
|
|
<p>When no arguments are specified, Ant looks for a <code>build.xml</code>
|
|
|
|
file in the current directory and, if found, uses that file as the
|
2002-06-22 23:38:38 +00:00
|
|
|
build file and runs the target specified in the <code>default</code>
|
|
|
|
attribute of the <code><project></code> tag.
|
|
|
|
To make Ant use
|
|
|
|
a build file other than <code>build.xml</code>, use the command-line
|
|
|
|
option <nobr><code>-buildfile <i>file</i></code></nobr>,
|
|
|
|
where <i>file</i> is the name of the build file you want to use.</p>
|
|
|
|
If you use the <nobr><code>-find [<i>file</i>]</code></nobr> option,
|
|
|
|
Ant will search for a build file first in the current directory, then in
|
|
|
|
the parent directory, and so on, until either a build file is found or the root
|
|
|
|
of the filesystem has been reached. By default, it will look for a build file
|
|
|
|
called <code>build.xml</code>. To have it search for a build file other
|
|
|
|
than <code>build.xml</code>, specify a file argument.
|
|
|
|
<strong>Note:</strong> If you include any other flags or arguments
|
|
|
|
on the command line after
|
|
|
|
the <nobr><code>-find</code></nobr> flag, you must include the file argument
|
|
|
|
for the <nobr><code>-find</code></nobr> flag, even if the name of the
|
|
|
|
build file you want to find is <code>build.xml</code>.
|
|
|
|
|
|
|
|
<p>You can also set <a href="using.html#properties">properties</a> on the
|
|
|
|
command line. This can be done with
|
2001-04-10 07:06:37 +00:00
|
|
|
the <nobr><code>-D<i>property</i>=<i>value</i></code></nobr> option,
|
|
|
|
where <i>property</i> is the name of the property,
|
2002-06-22 23:38:38 +00:00
|
|
|
and <i>value</i> is the value for that property. If you specify a
|
|
|
|
property that is also set in the build file
|
|
|
|
(see the <a href="CoreTasks/property.html">property</a> task),
|
|
|
|
the value specified on the
|
|
|
|
command line will override the value specified in the
|
|
|
|
build file.
|
|
|
|
Defining properties on the command line can also be used to pass in
|
|
|
|
the value of environment variables - just pass
|
|
|
|
<nobr><code>-DMYVAR=%MYVAR%</code></nobr> (Windows) or
|
2001-04-10 07:06:37 +00:00
|
|
|
<nobr><code>-DMYVAR=$MYVAR</code></nobr> (Unix)
|
2002-06-22 23:38:38 +00:00
|
|
|
to Ant. You can then access
|
|
|
|
these variables inside your build file as <code>${MYVAR}</code>.
|
|
|
|
You can also access environment variables using the
|
|
|
|
<a href="CoreTasks/property.html"> property</a> task's
|
|
|
|
<code>environment</code> attribute.
|
2001-12-13 17:16:26 +00:00
|
|
|
</p>
|
2001-04-10 07:06:37 +00:00
|
|
|
|
2002-06-22 23:38:38 +00:00
|
|
|
<p>Options that affect the amount of logging output by Ant are:
|
|
|
|
<nobr><code>-quiet</code></nobr>,
|
2001-04-10 07:06:37 +00:00
|
|
|
which instructs Ant to print less
|
2002-06-22 23:38:38 +00:00
|
|
|
information to the console;
|
2001-04-10 07:06:37 +00:00
|
|
|
<nobr><code>-verbose</code></nobr>, which causes Ant to print
|
2001-12-13 17:16:26 +00:00
|
|
|
additional information to the console; and <nobr><code>-debug</code></nobr>,
|
|
|
|
which causes Ant to print considerably more additional information.
|
|
|
|
</p>
|
2001-04-10 07:06:37 +00:00
|
|
|
|
|
|
|
<p>It is also possible to specify one or more targets that should be executed.
|
|
|
|
When omitted, the target that is specified in the
|
2001-12-13 17:16:26 +00:00
|
|
|
<code>default</code> attribute of the
|
|
|
|
<a href="using.html#projects"><code>project</code></a> tag is
|
2001-04-10 07:06:37 +00:00
|
|
|
used.</p>
|
|
|
|
|
2001-12-13 17:16:26 +00:00
|
|
|
<p>The <nobr><code>-projecthelp</code></nobr> option prints out a list
|
2002-06-22 23:38:38 +00:00
|
|
|
of the build file's targets. Targets that include a
|
|
|
|
<code>description</code> attribute are listed as "Main targets",
|
|
|
|
those without a <code>description</code> are listed as
|
|
|
|
"Subtargets", then the "Default" target is listed.
|
2001-04-10 07:06:37 +00:00
|
|
|
|
2001-12-13 17:16:26 +00:00
|
|
|
<h3><a name="options">Command-line Options Summary</a></h3>
|
2001-04-10 07:06:37 +00:00
|
|
|
<pre>ant [options] [target [target2 [target3] ...]]
|
|
|
|
Options:
|
2002-02-01 22:29:21 +00:00
|
|
|
-help print this message
|
|
|
|
-projecthelp print project help information
|
|
|
|
-version print the version information and exit
|
2002-09-02 12:29:38 +00:00
|
|
|
-diagnostics print information that might be helpful to
|
|
|
|
diagnose or report problems.
|
|
|
|
-quiet, -q be extra quiet
|
|
|
|
-verbose, -v be extra verbose
|
2002-02-01 22:29:21 +00:00
|
|
|
-debug print debugging information
|
|
|
|
-emacs produce logging information without adornments
|
2002-09-02 12:29:38 +00:00
|
|
|
-logfile <file> use given file for log
|
|
|
|
-l <file> ''
|
|
|
|
-logger <classname> the class which is to perform logging
|
|
|
|
-listener <classname> add an instance of class as a project listener
|
|
|
|
-buildfile <file> use given buildfile
|
|
|
|
-file <file> ''
|
|
|
|
-f <file> ''
|
|
|
|
-D<property>=<value> use value for given property
|
|
|
|
-propertyfile <name> load all properties from file with -D
|
|
|
|
properties taking precedence
|
|
|
|
-inputhandler <class> the class which will handle input requests
|
|
|
|
-find <file> search for buildfile towards the root of the
|
|
|
|
filesystem and use it
|
2001-04-10 07:06:37 +00:00
|
|
|
</pre>
|
2001-12-14 12:23:50 +00:00
|
|
|
<p>For more information about <code>-logger</code> and
|
2002-06-22 23:38:38 +00:00
|
|
|
<code>-listener</code> see
|
|
|
|
<a href="listeners.html">Loggers & Listeners</a>.
|
|
|
|
<p>For more information about <code>-inputhandler</code> see
|
|
|
|
<a href="inputhandler.html">InputHandler</a>.
|
|
|
|
|
2001-04-10 07:06:37 +00:00
|
|
|
<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>
|
2002-06-22 23:38:38 +00:00
|
|
|
<p>runs Ant using the <code>test.xml</code> file in the current directory, on
|
|
|
|
the target called <code>dist</code>.</p>
|
2001-04-10 07:06:37 +00:00
|
|
|
<blockquote>
|
|
|
|
<pre>ant -buildfile test.xml -Dbuild=build/classes dist</pre>
|
|
|
|
</blockquote>
|
2002-06-22 23:38:38 +00:00
|
|
|
<p>runs Ant using the <code>test.xml</code> file in the current directory, on
|
|
|
|
the target called <code>dist</code>, setting the <code>build</code> property
|
|
|
|
to the value <code>build/classes</code>.</p>
|
2001-04-10 07:06:37 +00:00
|
|
|
|
2001-12-13 17:16:26 +00:00
|
|
|
<h3><a name="files">Files</a></h3>
|
2001-06-13 15:29:47 +00:00
|
|
|
|
|
|
|
<p>The Ant wrapper script for Unix will source (read and evaluate) the
|
2002-06-22 23:38:38 +00:00
|
|
|
file <code>~/.antrc</code> before it does anything. On Windows, the Ant
|
|
|
|
wrapper batch-file invokes <code>%HOME%\antrc_pre.bat</code> at the start and
|
2001-06-13 15:29:47 +00:00
|
|
|
<code>%HOME%\antrc_post.bat</code> at the end. You can use these
|
2002-06-22 23:38:38 +00:00
|
|
|
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>
|
2001-06-13 15:29:47 +00:00
|
|
|
|
2001-12-13 17:16:26 +00:00
|
|
|
<h3><a name="envvars">Environment Variables</a></h3>
|
2001-06-13 15:29:47 +00:00
|
|
|
|
|
|
|
<p>The wrapper scripts use the following environment variables (if
|
|
|
|
set):</p>
|
|
|
|
|
|
|
|
<ul>
|
2001-10-17 00:27:34 +00:00
|
|
|
<li><code>JAVACMD</code> - full path of the Java executable. Use this
|
2001-06-13 15:29:47 +00:00
|
|
|
to invoke a different JVM than <code>JAVA_HOME/bin/java(.exe)</code>.</li>
|
|
|
|
|
2001-10-17 00:27:34 +00:00
|
|
|
<li><code>ANT_OPTS</code> - command-line arguments that should be
|
2002-04-25 00:38:12 +00:00
|
|
|
passed to the JVM. For example, you can define system properties or set
|
2001-06-13 15:29:47 +00:00
|
|
|
the maximum Java heap size here.</li>
|
2001-10-17 00:27:34 +00:00
|
|
|
|
|
|
|
<li><code>ANT_ARGS</code> - Ant command-line arguments. For example,
|
2002-06-22 23:38:38 +00:00
|
|
|
set <code>ANT_ARGS</code> to point to a different logger, include a
|
|
|
|
listener, and to include the <code>-find</code> flag.</li>
|
|
|
|
<strong>Note:</strong> If you include <code>-find</code>
|
|
|
|
in <code>ANT_ARGS</code>, you should include the name of the build file
|
|
|
|
to find, even if the file is called <code>build.xml</code>.
|
2001-06-13 15:29:47 +00:00
|
|
|
</ul>
|
|
|
|
|
2001-12-13 17:16:26 +00:00
|
|
|
<h2><a name="viajava">Running Ant via Java</a></h2>
|
2001-04-10 07:06:37 +00:00
|
|
|
<p>If you have installed Ant in the do-it-yourself way, Ant can be started
|
|
|
|
with:</p>
|
|
|
|
<blockquote>
|
|
|
|
<pre>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. This example assumes you have set your classpath to include:</p>
|
|
|
|
<ul>
|
|
|
|
<li><code>ant.jar</code></li>
|
|
|
|
<li>jars/classes for your XML parser</li>
|
|
|
|
<li>the JDK's required jar/zip files</li>
|
|
|
|
</ul>
|
|
|
|
<br>
|
|
|
|
<hr>
|
2002-06-01 12:26:43 +00:00
|
|
|
<p align="center">Copyright © 2000-2002 Apache Software Foundation. All rights
|
2001-04-10 07:06:37 +00:00
|
|
|
Reserved.</p>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|