ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ed <>
Subject I have a script calling a macro - how do I pass an element through?
Date Sat, 22 Mar 2008 13:37:27 GMT
I'd like to move some of my macros to scriptdef definitions, and I've
started to investigate how to do so.  One aspect is escaping me.  I
believe I understand how to pass an attribute, but I have a case where
I want to have my scriptdef pass an element on to the called macro.
>From the API doc, it's not clear to me how I should do that.  I've
googled for a tutorial or example, but I've been unable to find
anything (and I suspect my failed searches are due to me not knowing
the best search terms).

A trivialized example looks like so - how do I have wrapIt pass its
fileset element on to the call of doEcho?

   <macrodef name="doEcho">
      <attribute name="attr"/>
      <element name="fileset"/>
         <echo message="doEcho: attr is... @{attr}"/>

   <scriptdef name="wrapIt" language="groovy">
      <attribute name="attr"/>
      <element name="fileset" type="fileset"/>
         attr = attributes.get("attr");
         fileset = elements.get("fileset");

         doEcho = project.createTask("doEcho");
         doEcho.setDynamicAttribute("attr", "Inner call!");
         if (null != fileset) {
            // What goes here?

In the API doc, I've looked at MacroInstance, and it's clear I
shouldn't be using createDynamicElement().  I suspect I need to be
working with a MacroDef, but I don't see how to piece everything
together to get what I'm after.

Apologies for the entry level question,

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

View raw message