ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ed <ednoto...@gmail.com>
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"/>
      <sequential>
         <echo message="doEcho: attr is... @{attr}"/>
      </sequential>
   </macrodef>

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

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

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,
Ed

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message