rashok
rashok

Reputation: 13414

How do I call an Ant macro from inside another macrodef?

I have a build.xml, from here I call a macro:

<import file="macro_file.xml" />
<ant-macro message="Hello, World!" />

and my macro_file.xml file looks like this:

<macrodef name="ant-macro">
    <attributes name="message"/>
    <sequential>
        <echo message="@{message}" />
    </sequential>
</macrodef>

How can I call another macro inside the ant-macro macro?

I tried in the below manner, but its gives an error.

<macrodef name="ant-macro">
    <attributes name="message"/>
    <second-macro messge="hi"/>
    <sequential>
        <echo message="@{message}" />
    </sequential>
</macrodef>

The second-macro macro is also defined in the macro_file.xml file.

Upvotes: 3

Views: 4040

Answers (1)

JB Nizet
JB Nizet

Reputation: 691625

The macro executes everything inside its sequential element. Just put your second-macro call inside it:

<macrodef name="ant-macro">
    <attributes name="message"/>
    <sequential>
        <second-macro message="hi"/>
        <echo message="@{message}" />
    </sequential>
</macrodef>

Upvotes: 7

Related Questions