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