ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: classloading, ant, junit, more advanced question
Date Mon, 13 Sep 2004 06:28:10 GMT
On Sat, 11 Sep 2004, Dean D. Hiller <dhiller@avaya.com> wrote:

> Here is how my dream ant would work
> 
> 1. junit would have an ant task and have some standard file
> ant/resource.xml and other jars could have the same file

This is probably the main problem, <junit> is not part of the JUnit
project but Ant.  If the task and its dependencies are bundled
together, you don't face any problems, most of the time.

The rest of your dream is absolutely possible and mostly done via
antlibs already.

If a task is bundled with all the classes it depends upon, place a
file antlib.xml into its JAR file (right into the package you want to
use as its namespace URI) and you are more or less done:

> 2. junit is dropped into ant/lib or put in ant's classpath, or via a
> taskdef loaded in.

works out of the box when the file is in foo/bar/antlib.xml and you
use xmlns:mylib="antlib:foo.bar" on your <project> element.  Your
tasks will live in the mylib namespace.  No taskdef in the build file
at all.

> 3. ant seeing this jar with a resource.xml automatically loads it in
> a different classloader(it has to actually otherwise it may get the
> resource.xml from a different jar on accident).

Right now it will always use the same classloader that has loaded Ant.

> 4. The other option is someone does a taskdef with an attribute of
> jar="junit.jar"

Almost.

<taskdef resource="foo/bar/antlib.xml" classpath="foobar.jar"/>

and maybe a namespace URI.  Without the URI it should even work for
Ant 1.4.1.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message