ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <>
Subject Re: Requiring jar files in classpath (or $ANT_HOME/lib) for taskdefs
Date Mon, 15 Mar 2004 04:17:06 GMT
Keep in mind that this is only true in the case of optional tasks that ship 
with Ant.  You stated that tasks defined with <taskdef> require the task 
and its dependencies to be in the classpath or in ANT_HOME/lib which is 
completely false.  In fact, the only time when it is required to add 
dependencies to ANT_HOME/lib is when the task in question lives in 
ANT_HOME/lib.  The issue is not with Ant, but with classloading 
behavior.  Java2 classloading behavior states that child classloaders can 
see their parents but not vice-versa.  You can think of <classpath> entries 
as a child classloader to the parent (ANT_HOME/lib).  If a task is in 
ANT_HOME/lib and its dependencies are provided in <classpath> entries, the 
task won't be able to see the dependencies.  So, you can see why the 
official Ant optional tasks, being in ANT_HOME/lib, require their 
dependencies to be in ANT_HOME/lib.  To avoid this with your custom tasks 
which you would define via a <taskdef>, just make sure not to add the task 
to ANT_HOME/lib or else you will force users to put that tasks dependencies 
there as well.  If the task is provided via a <classpath> element, then the 
dependencies can be in that same <classpath> element or even in 
ANT_HOME/lib.  Your choice.

that said, there is the common problem where if you want to run JUnit 
tests, for instance, you must make sure any user of the build puts 
junit.jar in ANT_HOME/lib (or ${user.home}/.ant/lib with Ant-1.6+).  It is 
simply a burden to have to do this.  I believe JBoss has a concept of a 
"unified" classloader where everything is in the same classloader.  I'm not 
entirely sure how it works, but maybe Ant should do something like this so 
that libraries can be provide anywhere; in ANT_HOME/lib or in <classpath> 
entries without there being any difference between them.  Any Ant 
developers have an opinion on the subject?


At 07:12 PM 3/14/2004 -0800, you wrote:
>I'm not sure whether there's a real solution to this, but I'm starting
>to see a headache with requiring that classes required by tasks defined
>with "taskdef" are either in the global classpath, or stored in jar
>files copied to $ANT_HOME/lib.
>In the case of some tasks defined for WebLogic, there are numerous jar
>files that have to be set up for this.  The way this works, you can't
>just set a "classpath" nested element for "taskdef", which would be much
>more convenient.
>It makes it a little awkward to set up a reproducible build environment
>if you have to specify numerous jar files that have to be copied to
>$ANT_HOME/lib first.  This isn't even mentioning any issues with
>versioning of those jar files.  As tasks defined with taskdef get more
>complicated, this just gets worse.
>To unsubscribe, e-mail:
>For additional commands, e-mail:

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

View raw message