From d9575761aa1b2ad7957c6a9283eedbdd3dfb4f31 Mon Sep 17 00:00:00 2001
From: "Jesse N. Glick"
The external libraries required by each of the optional tasks is detailed in the Library Dependencies section. These external -libraries must be added to Ant's classpath, in any of the following ways +libraries must be added to Ant's classpath, in any of the following ways:
+ In ANT_HOME/lib
. This makes the JAR files available to all
+ Ant users and builds.
+
+ In ${user.home}/.ant/lib
(as of Ant 1.6). This
+ allows different users to add new libraries to Ant. All JAR files
added to this directory are available to command-line Ant.
-
On the command line with a -lib
parameter. This lets
you add new JAR files on a case-by-case basis.
-
+ In the CLASSPATH
environment variable. Avoid this; it makes
the JAR files visible to all Java applications, and causes
- no end of support calls.
+ no end of support calls. See below for details.
+
In some <classpath>
accepted by the task itself.
For example, as of Ant 1.7.0 you can run the <junit>
task without junit.jar
in Ant's own classpath, so long as
it is included (along with your program and tests) in the classpath
- passed when running the task. Where possible, this option is generally
+ passed when running the task.
+
+ Where possible, this option is generally to be preferred, as the Ant script itself can determine the best path to load the library from: via relative path from the basedir (if you keep the library under version control with your project), according to Ant properties, environment variables, Ivy downloads, whatever you like. -
CLASSPATH
environment variable
-The CLASSPATH environment variable is a source of many Ant support queries. As
+The CLASSPATH
environment variable is a source of many Ant support queries. As
the round trip time for diagnosis on the Ant user mailing list can be slow, and
because filing bug reports complaining about 'ant.bat' not working will be
rejected by the developers as WORKSFORME "this is a configuration problem, not a
@@ -290,21 +296,21 @@ simple steps.
CLASSPATH
. Ant does not need it, it only causes confusion
and breaks things.
CLASSPATH
, even if there is a space in a directory. This will break Ant, and it
is not needed. CLASSPATH
, as it breaks Ant's ability to quote the string. Again, this is
+not needed for the correct operation of the CLASSPATH
environment variable, even
if a DOS directory is to be added to the path. CLASSPATH
environment variable by setting the
-noclasspath
option on the command line. This is an easy way
to test for classpath-related problems.
-The usual symptom of CLASSPATH problems is that ant will not run with some error
-about not being able to find org.apache.tools.Ant.main
, or, if you have got the
+The usual symptom of CLASSPATH
problems is that ant will not run with some error
+about not being able to find org.apache.tools.ant.launch.Launcher
, or, if you have got the
quotes/backslashes wrong, some very weird Java startup error. To see if this is
-the case, run ant -noclasspath
or unset the CLASSPATH environment
+the case, run ant -noclasspath
or unset the CLASSPATH
environment
variable.
+You can also make your Ant script reject this environment +variable just by placing the following at the top of the script (or in an init target): +
++<property environment="env."/> +<property name="env.CLASSPATH" value=""/> +<fail message="Unset $CLASSPATH / %CLASSPATH% before running Ant!"> + <condition> + <not> + <equals arg1="${env.CLASSPATH}" arg2=""/> + </not> + </condition> +</fail> +
If you cannot get Ant installed or working, the Ant user mailing list is the
best place to start with any problem. Please do your homework first, make sure
-that it is not a CLASSPATH problem, and run a CLASSPATH
problem, and run a diagnostics check to see what Ant thinks of its own
state. Why the user list, and not the developer list?
Because there are more users than developers, so more people who can help you.