ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ernst de Haan <>
Subject <classpath/> versus -lib for <taskdef/>s: Official statement?
Date Tue, 13 Jan 2004 22:54:59 GMT
IMHO an Ant buildfile should always be able to instruct Ant with regard to 
the CLASSPATH to use for <taskdef/>s.

What I mean is that if a task (like <junit/>) needs a certain CLASSPATH, 
then the writer of the Ant build script should be able to specify where the 
necessary classes can be found (the junit.jar file in the case of JUnit).

So instead of requiring the buildfile _executor_ having to specify the -lib 
command-line argument, the buildfile _author_ should be able to use a 

Also, it should not have to be necessary to have the pertaining JAR files in 
the Ant lib/ directory. An author of the buildfile (like myself) will 
typically want to create a self-sufficient buildfile and not have a list of 
X dependencies for the buildfile executor to comply to. The environment of 
the buildfile executor should be independent as much as possible from the 
running of the buildfile.

Q: Is there an official statement on this subject?

Currently with Ant 1.6.0, I find it annoying that I know at build authoring 
time where the necessary JAR files are located, but it is not until build 
time that I can specify this location.

For a testcase use the attached buildfiles to do the following:

1. Clean your CLASSPATH environment variable and make sure junit.jar is not 
in ${ANT_HOME}/lib or anywhere else in the Ant CLASSPATH.

2. Run 'ant -f build1.xml'.
Notice that the buildfile correctly states that JUnit is not available.
If you get no error, then the junit.jar is in the Ant CLASSPATH somewhere, 
please fix that. Otherwise you're okay, continue with step 3.

3. Run 'ant -f build1.xml -lib <dir>', where <dir> is a directory that 
contains junit.jar. Notice that the build is now successful. We can specify 
the correct CLASSPATH

4. Run 'ant -f build2.xml -Ddir=<dir>', where <dir> is again a directory 
that contains junit.jar. Notice that the check for the required class (line 
6-11) succeeds, but the <taskdef/> (line 12) fails.

IMO test 4 should probably succeed instead of fail.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message