What about some kind of idea similar to XML namespaces? MyTasks.jar ----------- contains com.develop.MyCustomAntTask and the manifest holds
Manifest-Version: 1.0 Ant-Task-Namespace: urn:developmentor.anttasks.v1 Ant-Task: mytaskdef com.develop.MyCustomAntTask (or maybe this needs to be a "task descriptor" buried somewhere inside the .jar file; either way, the idea is the same) In my build.xml file I write <ant:project xmlns:ant="http://jakarta.apache.org/Ant/v2" xmlns:mytasks="urn:developmentor.anttasks.v1"> <mytasks:mytaskdef attr1="foo" attr2="bar" /> </ant:project> When Ant starts up, it'd scan the .jar files in the "tasklib" directory, establish the namespace-per-tasklib mapping, and then use the XML namespaces-to-prefixes syntax to allow the author of the build script to use whatever prefix is desired. Very similar to how JSP taglibs work. Just a random thought out of the blue. Ted Neward {.NET||Java} Course Author & Instructor DevelopMentor (http://www.develop.com) http://www.javageeks.com/tneward/index.html > -----Original Message----- > From: Conor MacNeill [mailto:[EMAIL PROTECTED] > Sent: Friday, October 05, 2001 4:52 AM > To: [EMAIL PROTECTED] > Subject: Re: Optional tasks > > > Kevin Jones wrote: > > > How does ant 'know' about the optional tasks? Are they defined > as part of > > the Ant core? > > > > For example if I use the JUnit task Ant picks the taskdef directly from > > options.jar (or whatever this releases jar file is called. But > if I create > > my own task I have to put a taskdef in my build.xml file, even > if I put the > > jar file containing the task into ant\lib. I was wondering where the > > optional task magic comes from? > > > > > Kevin, there isn't much magic. All of the optional tasks that come with > Ant are defined in the default.properties resource within Ant, along > with the core tasks. The distinction between a core and an optional task > is somewhat fuzzy. In general a core task requires no additional > resources beyond those provided by the JDK and Ant itself. Optional > tasks usually require something more, that some Ant users may not have > installed. It maybe a third party library (jar) such as JUnit or it > could be something from the javax namespace. Further, IMHO, core tasks > are somewhat more fundamental in some way. Optional tasks are > effectively taskdef'd for you, but without the opportunity to specify > the classpath, etc. They are required to be on the classpath, which the > optional.jar normally is. > > Overall the mechanism is rather unsatisfactory and we have long > considered a different approach of task libraries which when you drop > them into your ANT_HOME/lib area would automatically make the tasks > available, subject to some mechanism to handle ambiguous tasknames. > > Conor > > > > > > >
