ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wolfgang Häfelinger <>
Subject Re: how to access a MacroDef?
Date Wed, 07 Jun 2006 08:30:10 GMT
Allright, it appears much more easier than expected.

ComponentHelper componenthelper;
Object obj;
MacroInstance instance;

componenthelper = ComponentHelper.getComponentHelper(project());
obj             = componentHelper.createComponent(mymacroname);
instance        = (MacroInstance)obj;

Appears that there's no need to call setProject() or setOwningTarget() on 
the macro's 

However, not sure whether this is the "right" way to do. Perhaps Peter can 
on this.

Thanks for all help so far.


"Dominique Devienne" <> 
06-06-2006 19:41
Please respond to
"Ant Developers List" <>

"Ant Developers List" <>

Re: how to access a MacroDef?

> I tried something like
>  ComponentHelper componenthelper =
> ComponentHelper.getComponentHelper(project());
>  MacroDef def = (MacroDef)
> componenthelper.getTaskDefinitions().get(mymacroname);
> just in order to understand that Hastable getTaskDefinitions() contains 
> String => Class relation.
> So where are those MacroDef's hidden?

So your 'def' is null, right?

Try not casting it to MacroDef, and see which kind of Java Class is
returned, if any. It may be an UnknownElement (my guess), a
MacroInstance, etc...

>From the UE, you may be able to get a MacroInstance or a MacroDef, and
if the later, configure it into a MacroInstance, which is what you
want to run.

I vaguely know this code only. Peter's the expert. --D

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message