Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Nested types in a custom ant task

22 views
Skip to first unread message

Nick

unread,
Dec 21, 2008, 9:55:51 AM12/21/08
to
Hi All,

I'm creating a custom ant task and would like to have nested elements
inside this task that indicate a list of exporters that should be used
to export the results of the ant task.

Suffice to say there is an interface called

com.company.Exporter

and some classes:

com.company.FirstCustomExporter implements Exporter
com.company.SecondCustomExporter implements Exporter

...that export different things

According to the Ant manual I should be able to have an Ant task like
so:

class MyAntTask extends Task {

...
public void add( Exporter ex ) {
...
}

}

And then have in my build file

<taskdef name="myanttask" class="com.company.MyAntTask" />
<typedef name="firstcustomexporter"
class="com.company.FirstCustomExporter" />
<typedef name="secondcustomexporter"
class="com.company.SecondCustomExporter" />

<myanttask>
<firstcustomexporter />
<secondcustomexporter />
</myanttask>

However when I try to do things this way all I get is:

'myanttask' doesn't support the nested element 'firstcustomexporter'

What is wrong with my logic? I even copied and pasted the code from
the "Writing your own task" tutorial and it doesn't work.

This is not an issue with classpaths, I've run ant -debug and you can
see all the relevant classes being loaded from the right places....

This is truly frustrating and any help would be greatly appreciated...
Surely writing an ant task is not this difficult, what have I missed??

Kind Regards,
Nick

John B. Matthews

unread,
Dec 21, 2008, 1:05:50 PM12/21/08
to
In article
<690128da-fb45-4e6c...@n33g2000pri.googlegroups.com>,
Nick <pva...@gmail.com> wrote:

Just a guess: If your task contains other tasks as nested elements, do
you need to implement TaskContainer:

<http://ant.apache.org/manual/develop.html>

--
John B. Matthews
trashgod at gmail dot com
http://home.roadrunner.com/~jbmatthews/

Nick

unread,
Dec 21, 2008, 2:10:38 PM12/21/08
to
On 21 Dec, 18:05, "John B. Matthews" <nos...@nospam.com> wrote:
> In article
> <690128da-fb45-4e6c-af95-89d1efab3...@n33g2000pri.googlegroups.com>,

>
>
>
>  Nick <pva...@gmail.com> wrote:
> > I'm creating a customanttask and would like to havenestedelements
> > inside this task that indicate a list of exporters that should be used
> > to export the results of theanttask.
>
> > Suffice to say there is an interface called
>
> > com.company.Exporter
>
> > and some classes:
>
> > com.company.FirstCustomExporter implements Exporter
> > com.company.SecondCustomExporter implements Exporter
>
> > ...that export different things
>
> > According to theAntmanual I should be able to have anAnttask like

> > so:
>
> > class MyAntTask extends Task {
>
> >    ...
> >    public void add( Exporter ex ) {
> >       ...
> >    }
>
> > }
>
> > And then have in my build file
>
> > <taskdef name="myanttask" class="com.company.MyAntTask" />
> > <typedef name="firstcustomexporter"
> > class="com.company.FirstCustomExporter" />
> > <typedef name="secondcustomexporter"
> > class="com.company.SecondCustomExporter" />
>
> > <myanttask>
> >     <firstcustomexporter />
> >     <secondcustomexporter />
> > </myanttask>
>
> > However when I try to do things this way all I get is:
>
> > 'myanttask' doesn't support thenestedelement 'firstcustomexporter'

>
> > What is wrong with my logic? I even copied and pasted the code from
> > the "Writing your own task" tutorial and it doesn't work.
>
> > This isnotan issue with classpaths, I've runant-debug and you can

> > see all the relevant classes being loaded from the right places....
>
> > This is truly frustrating and any help would be greatly appreciated...
> > Surely writing ananttask isnotthis difficult, what have I missed??
>
> Just a guess: If your task contains other tasks asnestedelements, do

> you need to implement TaskContainer:
>
> <http://ant.apache.org/manual/develop.html>
>
> --
> John B. Matthews
> trashgod at gmail dot comhttp://home.roadrunner.com/~jbmatthews/

Hi John,

No it's just types that are nested, and I added that interface just to
see if it would fix the problem, but to no avail.

Thanks for replying!

-Nick

0 new messages