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
