ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Barclay <>
Subject Re: Ant2 - automatic taskdef registration?
Date Fri, 18 May 2001 16:13:59 GMT
Tim Dawson wrote:
> ...
> Maybe this has already been proposed, but I looked in the Ant2 features and
> didn't see anything about automatic taskdef registration.
> ... 
> I'd like to propose that instead of using the file in
> the package, that we just use a deployment
> descriptor - namely, meta-inf/ant-tasks.xml in the jar files, and when all
> the jar files inside the ANT_HOME/lib directory are loaded, Ant just looks
> for meta-inf/ant-tasks.xml, and when it finds one, it does the equivalent of
> the <taskdef> automatically for each defined task.

Great idea!  Yes, being able to automatically assimilate new task definitions
without having to edit a central configuration file is a good idea.  

To generalize your idea and to simplify its implementation, consider using
java.lang.ClassLoader.getSystemResources(String).  (Note the "s".) (See

and note how it lists multiple resources having the same name but existing in different Jar
or class directory hierarchies in the class search path.)

Using getSystemResources would generalize your idea to include class 
directories on the class path in addition to jar files.  (One could have an 
ant-tasks.xml resource file in a classes directory hierarchy, without having 
to pack everything into a jar file.)  This would allow more convenience in 
development, and would be consistent with newer Java configuration patterns.

The JNDI API, specifically javax.naming.InitialContext, works this way 
to make it easy to add and automatically register JNDI providers.  
InitialContext uses getSystemResources("") to look for resource
files in _all_ Jar files (or directory 
hierarchies) in the class search path.

Adding a JNDI provider module is as simple as adding its Jar file or classes 
root directory to the class path.  You don't have to edit edit any central 
file to register the provider module.

Daniel Barclay
Digital Focus

View raw message