ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wannheden, Knut" <knut.wannhe...@paranor.ch>
Subject RE: How do I create ant task elements nested two or more deep?
Date Wed, 21 Aug 2002 08:25:22 GMT
This new DynamicConfigurator indeed looks interesting.  If I understand it
correctly I can now also have attribute names with dashes and colons in it.
So the following example which is impossible with the old reflection style
is now possible with a DynamicConfigurator:

	<taskdef name="foo:bar" classname="foo.Bar"/>
	<foo:bar foo:baz-attribute="ok" xmlns:foo="urn:foo-names"/>

Of course this example would look like it uses XML namespaces but from Ant's
viewpoint it really doesn't matter.

--
knut

> -----Original Message-----
> From: Erik Hatcher [mailto:jakarta-ant@ehatchersolutions.com]
> Sent: Mittwoch, 21. August 2002 03:07
> To: Ant Developers List
> Subject: Re: How do I create ant task elements nested two or 
> more deep?
> 
> 
> jlcarpenter@household.com wrote:
> > In this case, only the class corresponding to sometask 
> needs to extend
> > org.apache.tools.ant.Task.
> 
> Well, technically, it does not even have to extend Task.  An Ant task 
> simply must have an execute() method, that is all.  But its 
> recommended 
> to extend Task for logging and Project access.
> 
> > Now consider the following build file for which I don't 
> understand how to
> > create the ant task.
> > 
> >       <target name="somefancytarget">
> >             <somefancytask attribute1="bla">
> >                   <subfancyelementA attribute2="bla">
> >                         <subfancyelementB attribute3="bla"/>
> >                         <subfancyelementB attribute3="bla"/>
> >                   </subfancyelementA>
> >             </somefancytask>
> >       </target>
> > 
> > Can subfancyelementA and subfancyelementB still be simple container
> > classes?
> 
> Yes.  The same mechanism for populating a Task with element/attribute 
> information is used from your custom task and as far down as 
> you want to 
> go. No difference whatsoever, actually.
> 
> 
> > If so would the class corresponding to subfancyelementA 
> need to implement
> > addSubFancyElementB, addConfiguredSubFancyElementB, or
> > createSubFancyElementB?
> 
> Yup.
> 
> But there is another way to do this with Ant 1.5.  Implement the 
> DynamicConfigurator interface to make it more dynamic.  This might be 
> overkill for what you're doing, but you ask a generic 
> question, and you 
> get a generic answer!  :)  But, seriously, if you need/want 
> to have the 
> element names be dynamically available, then 
> DynamicConfigurator is how 
> to do it.
> 
> 
> > If the above guesses are wrong, can someone explain what I 
> should be doing?
> 
> You're on the right track.
> 
> 	Erik
> 
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message