ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Dawson <tdaw...@wamnet.com>
Subject Ant 1.5... loading tasks from jars?
Date Fri, 05 Oct 2001 16:09:02 GMT
I made the suggestion back in May to allow loading tasks from jars (a
tasklib, if you will), and I know it is currently listed in the 2.0
requested features, but it appears to be possible today...

<taskdef resource="meta-inf/ant.tdf">
  <classpath>
    <pathelement location="mylib/mytasks.jar"/>
  </classpath>
</taskdef>

Of course, this is a completely non-obvious solution, which is why its still
a requested feature. :-)

I believe what is wanted by people is something more along the lines of:

<tasklib file="mylib/mytasks.jar"/>

Where we have a well-defined name for the resource, and its easy from there
to grab third-party (or internally developed) jars and pull your tasks in
with a minimum of pain. (and a maximum of readability and understandability)

Now, knowing that "shortcuts" are generally dismissed out of hand around
here, I thought I'd take this the next step forward and comment that this
isn't just a shortcut, its a packaging standardization.  Not only would
having a simple task make packaging and importing tasks easier, but having
the well-defined name would also allow for automatic inclusion of tasks from
jar files found in ANT_HOME/lib.

Doing the automatic inclusion of tasks from jar files in the lib dir would
be easily implemented using ClassLoader.getResources() (suggested by Dan
Barclay back in May when this topic came up initially) and would really
improve the way Ant currently packages the optional tasks.  It is really
quite strange that the main ant.jar file has a defaults.properties file that
contains taskdefs for optional tasks.  Both ant.jar and optional.jar should
have a "meta-inf/ant.tdf" (or whatever we use for the standard) file to
contain a list of what tasks are inside that jar file.

Tim

Mime
View raw message