You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Xu Xin <an...@gmail.com> on 2007/02/19 09:19:15 UTC

how to get the configured nested tasks from Macrodef?

Hellow everyone,

I am working with ANT 1.6.5, have a question for MacroDef: how can I get the
configured nested tasks from <macrodef>?

suppose  I have the following macrodef template,
 <macrodef name="myjunit">
    <attribute name="test"/>
    <sequential>

         <junit fork="false">
           <classpath refid="test.cp"/>
          <sysproperty key="color" value="red"/>
          <test name="@{test}"/>

        </junit>

    </sequential>
 </macrodef>

and I have a following target:

  <target name="test">
     <myjunit test="sometest.Test1"/>
 </target>

what I want is that I have a "detecting" code to search for the occurrence
of a particular macro and get the well configured (element/attribute have
been already substituted) nested task, so the above example,  I need to the
get  the identical tasks from "test" target:

    <sequential>

         <junit fork="false">
           <classpath refid="test.cp"/>
          <sysproperty key="color" value="red"/>
          <test name="sometest.Test1"/>
        </junit>

    </sequential>

I looked at the MacroInstance, it seems like all element/attribute
substitution're performed when we actually run it.

Is it possible I can still get the nested configured tasks from
MacroInstance without running it?

One more question:

If I can get the configured tasks from marodef, suppose I will change
something against them, will the changes be persisted cross multiple macro
invocation? Now, MacroInstance will likely do a copy everytime it runs.


-- 
anfernee