1 | <!--
|
---|
2 | Licensed to the Apache Software Foundation (ASF) under one or more
|
---|
3 | contributor license agreements. See the NOTICE file distributed with
|
---|
4 | this work for additional information regarding copyright ownership.
|
---|
5 | The ASF licenses this file to You under the Apache License, Version 2.0
|
---|
6 | (the "License"); you may not use this file except in compliance with
|
---|
7 | the License. You may obtain a copy of the License at
|
---|
8 |
|
---|
9 | http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 |
|
---|
11 | Unless required by applicable law or agreed to in writing, software
|
---|
12 | distributed under the License is distributed on an "AS IS" BASIS,
|
---|
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
14 | See the License for the specific language governing permissions and
|
---|
15 | limitations under the License.
|
---|
16 | -->
|
---|
17 | <html>
|
---|
18 |
|
---|
19 | <head>
|
---|
20 | <meta http-equiv="Content-Language" content="en-us">
|
---|
21 | <link rel="stylesheet" type="text/css" href="stylesheets/style.css">
|
---|
22 | <title>Running Apache Ant</title>
|
---|
23 | </head>
|
---|
24 |
|
---|
25 | <body>
|
---|
26 |
|
---|
27 | <h1>Running Ant</h1>
|
---|
28 | <h2><a name="commandline">Command Line</a></h2>
|
---|
29 | <p> If you've installed Ant as described in the
|
---|
30 | <a href="install.html"> Installing Ant</a> section,
|
---|
31 | running Ant from the command-line is simple: just type
|
---|
32 | <code>ant</code>.</p>
|
---|
33 | <p>When no arguments are specified, Ant looks for a <code>build.xml</code>
|
---|
34 | file in the current directory and, if found, uses that file as the
|
---|
35 | build file and runs the target specified in the <code>default</code>
|
---|
36 | attribute of the <code><project></code> tag.
|
---|
37 | To make Ant use
|
---|
38 | a build file other than <code>build.xml</code>, use the command-line
|
---|
39 | option <nobr><code>-buildfile <i>file</i></code></nobr>,
|
---|
40 | where <i>file</i> is the name of the build file you want to use.</p>
|
---|
41 | If you use the <nobr><code>-find [<i>file</i>]</code></nobr> option,
|
---|
42 | Ant will search for a build file first in the current directory, then in
|
---|
43 | the parent directory, and so on, until either a build file is found or the root
|
---|
44 | of the filesystem has been reached. By default, it will look for a build file
|
---|
45 | called <code>build.xml</code>. To have it search for a build file other
|
---|
46 | than <code>build.xml</code>, specify a file argument.
|
---|
47 | <strong>Note:</strong> If you include any other flags or arguments
|
---|
48 | on the command line after
|
---|
49 | the <nobr><code>-find</code></nobr> flag, you must include the file argument
|
---|
50 | for the <nobr><code>-find</code></nobr> flag, even if the name of the
|
---|
51 | build file you want to find is <code>build.xml</code>.
|
---|
52 |
|
---|
53 | <p>You can also set <a href="using.html#properties">properties</a> on the
|
---|
54 | command line. This can be done with
|
---|
55 | the <nobr><code>-D<i>property</i>=<i>value</i></code></nobr> option,
|
---|
56 | where <i>property</i> is the name of the property,
|
---|
57 | and <i>value</i> is the value for that property. If you specify a
|
---|
58 | property that is also set in the build file
|
---|
59 | (see the <a href="CoreTasks/property.html">property</a> task),
|
---|
60 | the value specified on the
|
---|
61 | command line will override the value specified in the
|
---|
62 | build file.
|
---|
63 | Defining properties on the command line can also be used to pass in
|
---|
64 | the value of environment variables; just pass
|
---|
65 | <nobr><code>-DMYVAR=%MYVAR%</code></nobr> (Windows) or
|
---|
66 | <nobr><code>-DMYVAR=$MYVAR</code></nobr> (Unix)
|
---|
67 | to Ant. You can then access
|
---|
68 | these variables inside your build file as <code>${MYVAR}</code>.
|
---|
69 | You can also access environment variables using the
|
---|
70 | <a href="CoreTasks/property.html"> property</a> task's
|
---|
71 | <code>environment</code> attribute.
|
---|
72 | </p>
|
---|
73 |
|
---|
74 | <p>Options that affect the amount of logging output by Ant are:
|
---|
75 | <nobr><code>-quiet</code></nobr>,
|
---|
76 | which instructs Ant to print less
|
---|
77 | information to the console;
|
---|
78 | <nobr><code>-verbose</code></nobr>, which causes Ant to print
|
---|
79 | additional information to the console; and <nobr><code>-debug</code></nobr>,
|
---|
80 | which causes Ant to print considerably more additional information.
|
---|
81 | </p>
|
---|
82 |
|
---|
83 | <p>It is also possible to specify one or more targets that should be executed.
|
---|
84 | When omitted, the target that is specified in the
|
---|
85 | <code>default</code> attribute of the
|
---|
86 | <a href="using.html#projects"><code>project</code></a> tag is
|
---|
87 | used.</p>
|
---|
88 |
|
---|
89 | <p>The <nobr><code>-projecthelp</code></nobr> option prints out a list
|
---|
90 | of the build file's targets. Targets that include a
|
---|
91 | <code>description</code> attribute are listed as "Main targets",
|
---|
92 | those without a <code>description</code> are listed as
|
---|
93 | "Other targets", then the "Default" target is listed
|
---|
94 | ("Other targets" are only displayed if there are no main
|
---|
95 | targets, or if Ant is invoked in -verbose or -debug mode).
|
---|
96 |
|
---|
97 | <h3><a name="options">Command-line Options Summary</a></h3>
|
---|
98 | <pre>ant [options] [target [target2 [target3] ...]]
|
---|
99 | Options:
|
---|
100 | -help, -h print this message
|
---|
101 | -projecthelp, -p print project help information
|
---|
102 | -version print the version information and exit
|
---|
103 | -diagnostics print information that might be helpful to
|
---|
104 | diagnose or report problems.
|
---|
105 | -quiet, -q be extra quiet
|
---|
106 | -verbose, -v be extra verbose
|
---|
107 | -debug, -d print debugging information
|
---|
108 | -emacs, -e produce logging information without adornments
|
---|
109 | -lib <path> specifies a path to search for jars and classes
|
---|
110 | -logfile <file> use given file for log
|
---|
111 | -l <file> ''
|
---|
112 | -logger <classname> the class which is to perform logging
|
---|
113 | -listener <classname> add an instance of class as a project listener
|
---|
114 | -noinput do not allow interactive input
|
---|
115 | -buildfile <file> use given buildfile
|
---|
116 | -file <file> ''
|
---|
117 | -f <file> ''
|
---|
118 | -D<property>=<value> use value for given property
|
---|
119 | -keep-going, -k execute all targets that do not depend
|
---|
120 | on failed target(s)
|
---|
121 | -propertyfile <name> load all properties from file with -D
|
---|
122 | properties taking precedence
|
---|
123 | -inputhandler <class> the class which will handle input requests
|
---|
124 | -find <file> (s)earch for buildfile towards the root of
|
---|
125 | -s <file> the filesystem and use it
|
---|
126 | -nice number A niceness value for the main thread:
|
---|
127 | 1 (lowest) to 10 (highest); 5 is the default
|
---|
128 | -nouserlib Run ant without using the jar files from ${user.home}/.ant/lib
|
---|
129 | -noclasspath Run ant without using CLASSPATH
|
---|
130 | -autoproxy Java 1.5+ : use the OS proxies
|
---|
131 | -main <class> override Ant's normal entry point
|
---|
132 | </pre>
|
---|
133 | <p>For more information about <code>-logger</code> and
|
---|
134 | <code>-listener</code> see
|
---|
135 | <a href="listeners.html">Loggers & Listeners</a>.
|
---|
136 | <p>For more information about <code>-inputhandler</code> see
|
---|
137 | <a href="inputhandler.html">InputHandler</a>.
|
---|
138 | <p>Easiest way of changing the exit-behaviour is subclassing the original main class:
|
---|
139 | <pre>
|
---|
140 | public class CustomExitCode extends org.apache.tools.ant.Main {
|
---|
141 | protected void exit(int exitCode) {
|
---|
142 | // implement your own behaviour, e.g. NOT exiting the JVM
|
---|
143 | }
|
---|
144 | }
|
---|
145 | </pre> and starting Ant with access (<tt>-lib path-to-class</tt>) to this class.
|
---|
146 | </p>
|
---|
147 |
|
---|
148 | <h3><a name="libs">Library Directories</a></h3>
|
---|
149 | <p>
|
---|
150 | Prior to Ant 1.6, all jars in the ANT_HOME/lib would be added to the CLASSPATH
|
---|
151 | used to run Ant. This was done in the scripts that started Ant. From Ant 1.6,
|
---|
152 | two directories are scanned by default and more can be added as required. The
|
---|
153 | default directories scanned are ANT_HOME/lib and a user specific directory,
|
---|
154 | ${user.home}/.ant/lib. This arrangement allows the Ant installation to be
|
---|
155 | shared by many users while still allowing each user to deploy additional jars.
|
---|
156 | Such additional jars could be support jars for Ant's optional tasks or jars
|
---|
157 | containing third-party tasks to be used in the build. It also allows the main Ant installation to be locked down which will please system adminstrators.
|
---|
158 | </p>
|
---|
159 |
|
---|
160 | <p>
|
---|
161 | Additional directories to be searched may be added by using the -lib option.
|
---|
162 | The -lib option specifies a search path. Any jars or classes in the directories
|
---|
163 | of the path will be added to Ant's classloader. The order in which jars are
|
---|
164 | added to the classpath is as follows:
|
---|
165 | </p>
|
---|
166 |
|
---|
167 | <ul>
|
---|
168 | <li>-lib jars in the order specified by the -lib elements on the command line</li>
|
---|
169 | <li>jars from ${user.home}/.ant/lib (unless -nouserlib is set)</li>
|
---|
170 | <li>jars from ANT_HOME/lib</li>
|
---|
171 | </ul>
|
---|
172 |
|
---|
173 | <p>
|
---|
174 | Note that the CLASSPATH environment variable is passed to Ant using a -lib
|
---|
175 | option. Ant itself is started with a very minimalistic classpath.
|
---|
176 | Ant should work perfectly well with an empty CLASSPATH environment variable,
|
---|
177 | something the the -noclasspath option actually enforces. We get many more support calls related to classpath problems (especially quoting problems) than
|
---|
178 | we like.
|
---|
179 |
|
---|
180 | </p>
|
---|
181 |
|
---|
182 | <p>
|
---|
183 | The location of ${user.home}/.ant/lib is somewhat dependent on the JVM. On Unix
|
---|
184 | systems ${user.home} maps to the user's home directory whilst on recent
|
---|
185 | versions of Windows it will be somewhere such as
|
---|
186 | C:\Documents and Settings\username\.ant\lib. You should consult your
|
---|
187 | JVM documentation for more details.
|
---|
188 | </p>
|
---|
189 |
|
---|
190 | <h3>Examples</h3>
|
---|
191 | <blockquote>
|
---|
192 | <pre>ant</pre>
|
---|
193 | </blockquote>
|
---|
194 | <p>runs Ant using the <code>build.xml</code> file in the current directory, on
|
---|
195 | the default target.</p>
|
---|
196 | <blockquote>
|
---|
197 | <pre>ant -buildfile test.xml</pre>
|
---|
198 | </blockquote>
|
---|
199 | <p>runs Ant using the <code>test.xml</code> file in the current directory, on
|
---|
200 | the default target.</p>
|
---|
201 | <blockquote>
|
---|
202 | <pre>ant -buildfile test.xml dist</pre>
|
---|
203 | </blockquote>
|
---|
204 | <p>runs Ant using the <code>test.xml</code> file in the current directory, on
|
---|
205 | the target called <code>dist</code>.</p>
|
---|
206 | <blockquote>
|
---|
207 | <pre>ant -buildfile test.xml -Dbuild=build/classes dist</pre>
|
---|
208 | </blockquote>
|
---|
209 | <p>runs Ant using the <code>test.xml</code> file in the current directory, on
|
---|
210 | the target called <code>dist</code>, setting the <code>build</code> property
|
---|
211 | to the value <code>build/classes</code>.</p>
|
---|
212 |
|
---|
213 | <blockquote>
|
---|
214 | <pre>ant -lib /home/ant/extras</pre>
|
---|
215 | </blockquote>
|
---|
216 | <p>runs Ant picking up additional task and support jars from the
|
---|
217 | /home/ant/extras location
|
---|
218 | </p>
|
---|
219 |
|
---|
220 | <h3><a name="files">Files</a></h3>
|
---|
221 |
|
---|
222 | <p>The Ant wrapper script for Unix will source (read and evaluate) the
|
---|
223 | file <code>~/.antrc</code> before it does anything. On Windows, the Ant
|
---|
224 | wrapper batch-file invokes <code>%HOME%\antrc_pre.bat</code> at the start and
|
---|
225 | <code>%HOME%\antrc_post.bat</code> at the end. You can use these
|
---|
226 | files, for example, to set/unset environment variables that should only be
|
---|
227 | visible during the execution of Ant. See the next section for examples.</p>
|
---|
228 |
|
---|
229 | <h3><a name="envvars">Environment Variables</a></h3>
|
---|
230 |
|
---|
231 | <p>The wrapper scripts use the following environment variables (if
|
---|
232 | set):</p>
|
---|
233 |
|
---|
234 | <ul>
|
---|
235 | <li><code>JAVACMD</code> - full path of the Java executable. Use this
|
---|
236 | to invoke a different JVM than <code>JAVA_HOME/bin/java(.exe)</code>.</li>
|
---|
237 |
|
---|
238 | <li><code>ANT_OPTS</code> - command-line arguments that should be
|
---|
239 | passed to the JVM. For example, you can define system properties or set
|
---|
240 | the maximum Java heap size here.</li>
|
---|
241 |
|
---|
242 | <li><code>ANT_ARGS</code> - Ant command-line arguments. For example,
|
---|
243 | set <code>ANT_ARGS</code> to point to a different logger, include a
|
---|
244 | listener, and to include the <code>-find</code> flag.</li>
|
---|
245 | <strong>Note:</strong> If you include <code>-find</code>
|
---|
246 | in <code>ANT_ARGS</code>, you should include the name of the build file
|
---|
247 | to find, even if the file is called <code>build.xml</code>.
|
---|
248 | </ul>
|
---|
249 |
|
---|
250 | <h3><a name="sysprops">Java System Properties</a></h3>
|
---|
251 | <p>Some of Ant's core classes can be configured via system properties.</p>
|
---|
252 | <p>Here is the result of a search through the codebase. Because system properties are
|
---|
253 | available via Project instance, I searched for them with a
|
---|
254 | <pre>
|
---|
255 | grep -r -n "getPropert" * > ..\grep.txt
|
---|
256 | </pre>
|
---|
257 | command. After that I filtered out the often-used but not-so-important values (most of them
|
---|
258 | read-only values): <i>path.separator, ant.home, basedir, user.dir, os.name,
|
---|
259 | line.separator, java.home, java.version, java.version, user.home, java.class.path</i><br>
|
---|
260 | And I filtered out the <i>getPropertyHelper</i> access.</p>
|
---|
261 | <table border="1">
|
---|
262 | <tr>
|
---|
263 | <th>property name</th>
|
---|
264 | <th>valid values /default value</th>
|
---|
265 | <th>description</th>
|
---|
266 | </tr>
|
---|
267 | <tr>
|
---|
268 | <td><code>ant.build.javac.source</code></td>
|
---|
269 | <td>Source-level version number</td>
|
---|
270 | <td>Default <em>source</em> value for <javac>/<javadoc></td>
|
---|
271 | </tr>
|
---|
272 | <tr>
|
---|
273 | <td><code>ant.build.javac.target</code></td>
|
---|
274 | <td>Class-compatibility version number</td>
|
---|
275 | <td>Default <em>target</em> value for <javac></td>
|
---|
276 | </tr>
|
---|
277 | <tr>
|
---|
278 | <td><code>ant.executor.class</code></td>
|
---|
279 | <td>classname; default is org. apache. tools. ant. helper. DefaultExecutor</td>
|
---|
280 | <td><b>Since Ant 1.6.3</b> Ant will delegate Target invocation to the
|
---|
281 | org.apache.tools.ant.Executor implementation specified here.
|
---|
282 | </td>
|
---|
283 | </tr>
|
---|
284 |
|
---|
285 | <tr>
|
---|
286 | <td><code>ant.file</code></td>
|
---|
287 | <td>read only: full filename of the build file</td>
|
---|
288 | <td>This is set to the name of the build file. In
|
---|
289 | <a href="CoreTasks/import.html">
|
---|
290 | <import>-ed</a> files, this is set to the containing build file.
|
---|
291 | </td>
|
---|
292 | </tr>
|
---|
293 |
|
---|
294 | <tr>
|
---|
295 | <td><code>ant.file.*</code></td>
|
---|
296 | <td>read only: full filename of the build file of Ant projects
|
---|
297 | </td>
|
---|
298 | <td>This is set to the name of a file by project;
|
---|
299 | this lets you determine the location of <a href="CoreTasks/import.html">
|
---|
300 | <import>-ed</a> files,
|
---|
301 | </td>
|
---|
302 | </tr>
|
---|
303 |
|
---|
304 | <tr>
|
---|
305 | <td><code>ant.input.properties</code></td>
|
---|
306 | <td>filename (required)</td>
|
---|
307 | <td>Name of the file holding the values for the
|
---|
308 | <a href="inputhandler.html">PropertyFileInputHandler</a>.
|
---|
309 | </td>
|
---|
310 | </tr>
|
---|
311 | <tr>
|
---|
312 | <td><code>ant.logger.defaults</code></td>
|
---|
313 | <!-- add the blank after the slash, so the browser can do a line break -->
|
---|
314 | <td>filename (optional, default '/org/ apache/ tools/ ant/ listener/ defaults.properties')</td>
|
---|
315 | <td>Name of the file holding the color mappings for the
|
---|
316 | <a href="listeners.html#AnsiColorLogger">AnsiColorLogger</a>.
|
---|
317 | </td>
|
---|
318 | </tr>
|
---|
319 | <tr>
|
---|
320 | <td><code>ant.netrexxc.*</code></td>
|
---|
321 | <td>several formats</td>
|
---|
322 | <td>Use specified values as defaults for <a href="OptionalTasks/netrexxc.html">netrexxc</a>.
|
---|
323 | </td>
|
---|
324 | </tr>
|
---|
325 | <tr>
|
---|
326 | <td><code>ant.PropertyHelper</code></td>
|
---|
327 | <td>ant-reference-name (optional)</td>
|
---|
328 | <td>Specify the PropertyHelper to use. The object must be of the type
|
---|
329 | org.apache.tools.ant.PropertyHelper. If not defined an object of
|
---|
330 | org.apache.tools.ant.PropertyHelper will be used as PropertyHelper.
|
---|
331 | </td>
|
---|
332 | </tr>
|
---|
333 | <tr>
|
---|
334 | <td><code>ant.regexp.regexpimpl</code></td>
|
---|
335 | <td>classname</td>
|
---|
336 | <td>classname for a RegExp implementation; if not set Ant tries to
|
---|
337 | find another (JDK14+, Apache Oro...);
|
---|
338 | <a href="CoreTypes/mapper.html#regexp-mapper">RegExp-Mapper</a>
|
---|
339 | "Choice of regular expression implementation"
|
---|
340 | </td>
|
---|
341 | </tr>
|
---|
342 | <tr>
|
---|
343 | <td><code>ant.reuse.loader</code></td>
|
---|
344 | <td>boolean</td>
|
---|
345 | <td>allow to reuse classloaders
|
---|
346 | used in org.apache.tools.ant.util.ClasspathUtil
|
---|
347 | </td>
|
---|
348 | </tr>
|
---|
349 | <tr>
|
---|
350 | <td><code>ant.XmlLogger.stylesheet.uri</code></td>
|
---|
351 | <td>filename (default 'log.xsl')</td>
|
---|
352 | <td>Name for the stylesheet to include in the logfile by
|
---|
353 | <a href="listeners.html#XmlLogger">XmlLogger</a>.
|
---|
354 | </td>
|
---|
355 | </tr>
|
---|
356 | <tr>
|
---|
357 | <td><code>build.compiler</code></td>
|
---|
358 | <td>name</td>
|
---|
359 | <td>Specify the default compiler to use.
|
---|
360 | see <a href="CoreTasks/javac.html">javac</a>,
|
---|
361 | <a href="OptionalTasks/ejb.html#ejbjar_weblogic">EJB Tasks</a>
|
---|
362 | (compiler attribute),
|
---|
363 | <a href="OptionalTasks/javah.html">javah</a>
|
---|
364 | </td>
|
---|
365 | </tr>
|
---|
366 | <tr>
|
---|
367 | <td><code>build.compiler.emacs</code></td>
|
---|
368 | <td>boolean (default false)</td>
|
---|
369 | <td>Enable emacs-compatible error messages.
|
---|
370 | see <a href="CoreTasks/javac.html">javac</a> "Jikes Notes"
|
---|
371 | </td>
|
---|
372 | </tr>
|
---|
373 | <tr>
|
---|
374 | <td><code>build.compiler.fulldepend</code></td>
|
---|
375 | <td>boolean (default false)</td>
|
---|
376 | <td>Enable full dependency checking
|
---|
377 | see <a href="CoreTasks/javac.html">javac</a> "Jikes Notes"
|
---|
378 | </td>
|
---|
379 | </tr>
|
---|
380 | <tr>
|
---|
381 | <td><code>build.compiler.jvc.extensions</code></td>
|
---|
382 | <td>boolean (default true)</td>
|
---|
383 | <td>enable Microsoft extensions of their java compiler
|
---|
384 | see <a href="CoreTasks/javac.html">javac</a> "Jvc Notes"
|
---|
385 | </td>
|
---|
386 | </tr>
|
---|
387 | <tr>
|
---|
388 | <td><code>build.compiler.pedantic</code></td>
|
---|
389 | <td>boolean (default false)</td>
|
---|
390 | <td>Enable pedantic warnings.
|
---|
391 | see <a href="CoreTasks/javac.html">javac</a> "Jikes Notes"
|
---|
392 | </td>
|
---|
393 | </tr>
|
---|
394 | <tr>
|
---|
395 | <td><code>build.compiler.warnings</code></td>
|
---|
396 | <td>Deprecated flag</td>
|
---|
397 | <td> see <a href="CoreTasks/javac.html">javac</a> "Jikes Notes" </td>
|
---|
398 | </tr>
|
---|
399 | <tr>
|
---|
400 | <td><code>build.rmic</code></td>
|
---|
401 | <td>name</td>
|
---|
402 | <td>control the <a href="CoreTasks/rmic.html">rmic</a> compiler </td>
|
---|
403 | </tr>
|
---|
404 | <tr>
|
---|
405 | <td><code>build.sysclasspath</code></td>
|
---|
406 | <td>"only", something else</td>
|
---|
407 | <td>only: current threads get the actual class loader
|
---|
408 | (AntClassLoader.setThreadContextLoader()).
|
---|
409 | else: use core loader as default (ComponentHelper.initTasks()). Disable
|
---|
410 | changing the classloader (oata.taskdefs.Classloader.execute() experimental
|
---|
411 | task).
|
---|
412 | <!-- somewhere documented in the manual?? -->
|
---|
413 | </td>
|
---|
414 | </tr>
|
---|
415 | <tr>
|
---|
416 | <td><code>file.encoding</code></td>
|
---|
417 | <td>name of a supported character set (e.g. UTF-8, ISO-8859-1, US-ASCII)</td>
|
---|
418 | <td>use as default character set of email messages; use as default for source-, dest- and bundleencoding
|
---|
419 | in <a href="OptionalTasks/translate.html">translate</a> <br>
|
---|
420 | see JavaDoc of <a target="_blank" href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html">java.nio.charset.Charset</a>
|
---|
421 | for more information about character sets (not used in Ant, but has nice docs).
|
---|
422 | </td>
|
---|
423 | </tr>
|
---|
424 | <tr>
|
---|
425 | <td><code>jikes.class.path</code></td>
|
---|
426 | <td>path</td>
|
---|
427 | <td>The specified path is added to the classpath if jikes is used as compiler.</td>
|
---|
428 | </tr>
|
---|
429 | <tr>
|
---|
430 | <td><code>MailLogger.properties.file, MailLogger.*</code></td>
|
---|
431 | <td>filename (optional, defaults derived from Project instance)</td>
|
---|
432 | <td>Name of the file holding properties for sending emails by the
|
---|
433 | <a href="listeners.html#MailLogger">MailLogger</a>. Override properties set
|
---|
434 | inside the buildfile or via command line.
|
---|
435 | </td>
|
---|
436 | </tr>
|
---|
437 | <tr>
|
---|
438 | <td><code>org.apache.tools.ant.ProjectHelper</code></td>
|
---|
439 | <!-- add the blank after the slash, so the browser can do a line break -->
|
---|
440 | <td>classname (optional, default 'org.apache.tools.ant.ProjectHelper')</td>
|
---|
441 | <td>specifies the classname to use as ProjectHelper. The class must extend
|
---|
442 | org.apache.tools.ant.ProjectHelper.
|
---|
443 | </td>
|
---|
444 | </tr>
|
---|
445 | <tr>
|
---|
446 | <td><code>p4.port, p4.client, p4.user</code></td>
|
---|
447 | <td>several formats</td>
|
---|
448 | <td>Specify defaults for port-, client- and user-setting of the
|
---|
449 | <a href="OptionalTasks/perforce.html">perforce</a> tasks.
|
---|
450 | </td>
|
---|
451 | </tr>
|
---|
452 | <tr>
|
---|
453 | <td><code>websphere.home
|
---|
454 | <td>path</td>
|
---|
455 | <td>Points to home directory of websphere.
|
---|
456 | see <a href="OptionalTasks/ejb.html#ejbjar_websphere">EJB Tasks</a>
|
---|
457 | </td>
|
---|
458 | </tr>
|
---|
459 | <tr>
|
---|
460 | <td><code>XmlLogger.file
|
---|
461 | <td>filename (default 'log.xml')</td>
|
---|
462 | <td>Name for the logfile for <a href="listeners.html#MailLogger">MailLogger</a>.
|
---|
463 | </td>
|
---|
464 | </tr>
|
---|
465 | </table>
|
---|
466 |
|
---|
467 | <p>
|
---|
468 | If new properties get added (it happens), expect them to appear under the
|
---|
469 | "ant." and "org.apache.tools.ant" prefixes, unless the developers have a
|
---|
470 | very good reason to use another prefix. Accordingly, please avoid using
|
---|
471 | properties that begin with these prefixes. This protects you from future
|
---|
472 | Ant releases breaking your build file.
|
---|
473 | </p>
|
---|
474 | <h3>return code</h3>
|
---|
475 | <p>the ant start up scripts (in their Windows and Unix version) return
|
---|
476 | the return code of the java program. So a successful build returns 0,
|
---|
477 | failed builds return other values.
|
---|
478 | </p>
|
---|
479 |
|
---|
480 | <h2><a name="cygwin">Cygwin Users</a></h2>
|
---|
481 | <p>The Unix launch script that come with Ant works correctly with Cygwin. You
|
---|
482 | should not have any problems launching Ant from the Cygwin shell. It is
|
---|
483 | important to note, however, that once Ant is running it is part of the JDK
|
---|
484 | which operates as a native Windows application. The JDK is not a Cygwin
|
---|
485 | executable, and it therefore has no knowledge of Cygwin paths, etc. In
|
---|
486 | particular when using the <code><exec></code> task, executable names such
|
---|
487 | as "/bin/sh" will not work, even though these work from the Cygwin
|
---|
488 | shell from which Ant was launched. You can use an executable name such as
|
---|
489 | "sh" and rely on that command being available in the Windows path.
|
---|
490 | </p>
|
---|
491 |
|
---|
492 | <h2><a name="os2">OS/2 Users</a></h2>
|
---|
493 | <p>The OS/2 launch script was developed to perform complex tasks. It has two parts:
|
---|
494 | <code>ant.cmd</code> which calls Ant and <code>antenv.cmd</code> which sets the environment for Ant.
|
---|
495 | Most often you will just call <code>ant.cmd</code> using the same command line options as described
|
---|
496 | above. The behaviour can be modified by a number of ways explained below.</p>
|
---|
497 |
|
---|
498 | <p>Script <code>ant.cmd</code> first verifies whether the Ant environment is set correctly. The
|
---|
499 | requirements are:</p>
|
---|
500 | <ol>
|
---|
501 | <li>Environment variable <code>JAVA_HOME</code> is set.</li>
|
---|
502 | <li>Environment variable <code>ANT_HOME</code> is set.</li>
|
---|
503 | <li>Environment variable <code>CLASSPATH</code> is set and contains at least one element from
|
---|
504 | <code>JAVA_HOME</code> and at least one element from <code>ANT_HOME</code>.</li>
|
---|
505 | </ol>
|
---|
506 |
|
---|
507 | <p>If any of these conditions is violated, script <code>antenv.cmd</code> is called. This script
|
---|
508 | first invokes configuration scripts if there exist: the system-wide configuration
|
---|
509 | <code>antconf.cmd</code> from the <code>%ETC%</code> directory and then the user configuration
|
---|
510 | <code>antrc.cmd</code> from the <code>%HOME%</code> directory. At this moment both
|
---|
511 | <code>JAVA_HOME</code> and <code>ANT_HOME</code> must be defined because <code>antenv.cmd</code>
|
---|
512 | now adds <code>classes.zip</code> or <code>tools.jar</code> (depending on version of JVM) and
|
---|
513 | everything from <code>%ANT_HOME%\lib</code> except <code>ant-*.jar</code> to
|
---|
514 | <code>CLASSPATH</code>. Finally <code>ant.cmd</code> calls per-directory configuration
|
---|
515 | <code>antrc.cmd</code>. All settings made by <code>ant.cmd</code> are local and are undone when the
|
---|
516 | script ends. The settings made by <code>antenv.cmd</code> are persistent during the lifetime of the
|
---|
517 | shell (of course unless called automatically from <code>ant.cmd</code>). It is thus possible to call
|
---|
518 | <code>antenv.cmd</code> manually and modify some settings before calling <code>ant.cmd</code>.</p>
|
---|
519 |
|
---|
520 | <p>Scripts <code>envset.cmd</code> and <code>runrc.cmd</code> perform auxiliary tasks. All scripts
|
---|
521 | have some documentation inside.</p>
|
---|
522 |
|
---|
523 | <h2><a name="viajava">Running Ant via Java</a></h2>
|
---|
524 | <p>If you have installed Ant in the do-it-yourself way, Ant can be started
|
---|
525 | from one of two entry points:</p>
|
---|
526 | <blockquote>
|
---|
527 | <pre>java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]</pre>
|
---|
528 | </blockquote>
|
---|
529 |
|
---|
530 | <blockquote>
|
---|
531 | <pre>java -Dant.home=c:\ant org.apache.tools.ant.launch.Launcher [options] [target]</pre>
|
---|
532 | </blockquote>
|
---|
533 |
|
---|
534 | <p>
|
---|
535 | The first method runs Ant's traditional entry point. The second method uses
|
---|
536 | the Ant Launcher introduced in Ant 1.6. The former method does not support
|
---|
537 | the -lib option and all required classes are loaded from the CLASSPATH. You must
|
---|
538 | ensure that all required jars are available. At a minimum the CLASSPATH should
|
---|
539 | include:
|
---|
540 | </p>
|
---|
541 |
|
---|
542 | <ul>
|
---|
543 | <li><code>ant.jar</code> and <code>ant-launcher.jar</code></li>
|
---|
544 | <li>jars/classes for your XML parser</li>
|
---|
545 | <li>the JDK's required jar/zip files</li>
|
---|
546 | </ul>
|
---|
547 |
|
---|
548 | <p>
|
---|
549 | The latter method supports the -lib, -nouserlib, -noclasspath options and will
|
---|
550 | load jars from the specified ANT_HOME. You should start the latter with the most minimal
|
---|
551 | classpath possible, generally just the ant-launcher.jar.
|
---|
552 | </p>
|
---|
553 |
|
---|
554 | <a name="viaant"/>
|
---|
555 |
|
---|
556 | Ant can be started in Ant via the <code><java></code> command.
|
---|
557 | Here is an example:
|
---|
558 |
|
---|
559 | <pre>
|
---|
560 | <java
|
---|
561 | classname="org.apache.tools.ant.launch.Launcher"
|
---|
562 | fork="true"
|
---|
563 | failonerror="true"
|
---|
564 | dir="${sub.builddir}"
|
---|
565 | timeout="4000000"
|
---|
566 | taskname="startAnt"
|
---|
567 | >
|
---|
568 | <classpath>
|
---|
569 | <pathelement location="${ant.home}/lib/ant-launcher.jar"/>
|
---|
570 | </classpath>
|
---|
571 | <arg value="-buildfile"/>
|
---|
572 | <arg file="${sub.buildfile}"/>
|
---|
573 | <arg value="-Dthis=this"/>
|
---|
574 | <arg value="-Dthat=that"/>
|
---|
575 | <arg value="-Dbasedir=${sub.builddir}"/>
|
---|
576 | <arg value="-Dthe.other=the.other"/>
|
---|
577 | <arg value="${sub.target}"/>
|
---|
578 | </java>
|
---|
579 | </pre>
|
---|
580 | <br>
|
---|
581 |
|
---|
582 |
|
---|
583 | </body>
|
---|
584 | </html>
|
---|