ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose Alberto Fernandez" <j_a_fernan...@yahoo.com>
Subject Re: Optional tasks
Date Tue, 09 Oct 2001 11:54:27 GMT
XML Namespaces have been suggested as part of Ant2, however I think the discussion has concentrated
on what would be the best way to use then which is simple and effective.

To me the only good reason to have namespaces is to be able to use in the same project tasks
from different sources that may be using the same names. In current Ant this is not possible
since the name space is flat. For the use of libraries, we do not really require namespaces
but just a way to import (as Donald mentioned already) the task belonging to a particular
library.

I also prefer the manual declaration of the libraries being used as opposed to some auto-install
sort of facility. The reason for this is my believe that is much better to document in the
buildfile which resources are required than to assume that every user will find out by other
means. 

Once you accept this there is no reason to enforce that libraries are located in some especific
place, they can be anywhere including a remote location. ANT may provide a convinient location
(${ant.lib}) but it should be just that a convinience.

The next question is how this libraries interact with ClassLoaders. Should each library have
its own ClassLoader? Should they be able to share them? How about external libraries being
required? Shall one be able to specify an additional ClassPath for the library?

<tasklib name="lib1" location="mydir/mytasks.jar" />

  <lib1:mytask .... />

<tasklib location="${ant.lib}/optional.jar">
    <classpath path="${ant.lib}/junit.jar" />
</tasklib>

    <junit ..... />

This would allow a way to provide namespace support and otherwise simplifying things.

Now with all that many view from each one of us, no wonder we haven't really settle on one
yet.

Jose Alberto

----- Original Message ----- 
From: "Ted Neward" <tneward@javageeks.com>
To: <ant-dev@jakarta.apache.org>
Sent: Tuesday, October 09, 2001 6:57 AM
Subject: RE: Optional tasks


> 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:conor@cortexebusiness.com.au]
> > Sent: Friday, October 05, 2001 4:52 AM
> > To: ant-dev@jakarta.apache.org
> > 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
> >
> >
> >
> >
> >
> >
> >
> 


Mime
View raw message