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 defaults.properties file in > the org.apache.tools.ant.taskdefs 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 http://java.sun.com/j2se/1.3/docs/api/java/lang/ClassLoader.html#getResources(java.lang.String) and note how it lists multiple resources having the same name but existing in different Jar files 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("jndi.properties") to look for jndi.properties 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 -- Daniel Barclay Digital Focus [EMAIL PROTECTED]
