Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default element for Ant's macrodef?

Tags:

ant

I would like to create a macro as such:

<macrodef name="testing">
  <element name="test" implicit="yes"/>
  <sequential>
    <test/>
  </sequential>
</macrodef>

And then use it:

<testing>
  <echo message="hello world"/>
</testing>

However, I would like to specify a default for the implicit element... something like:

<macrodef name="testing">
  <element name="test" implicit="yes">
    <echo message="hello world"/>
  </element>
  <sequential>
    <test/>
  </sequential>
</macrodef>

So I can then use it as such:

<testing/>

Except where I want to change the default element.

Is this possible without defining a task via a Java class? So far, I don't see any documentation that indicates how to do it, if so.


Update

I ended up resolving my particular issue by using refid for filesets (which is what I actually was trying to pull into an element). Using the refid, it was simple to just use a macrodef attribute, which CAN have a default value.

Another alternative would be to create a new base macro which uses the element, and then I could have kept my existing macro as using that one... but still, there is no real default mechanism for an element (which would be nice).

So, Simon gets the answer since he's correct! Thanks!

like image 340
Mike Stone Avatar asked Apr 08 '09 18:04

Mike Stone


1 Answers

This is not possible based on the nested element element documentation for the macrodef task.

There is a Bugzilla issue open for exactly the functionality you describe, unfortunately it has been open since 2004.

like image 136
Simon Lieschke Avatar answered Sep 22 '22 06:09

Simon Lieschke