During the past weeks we've been going back and forth about a way to make <macrodef> even more powerful and easier to grasp at the same time.

The implementation in 1.6betas so far has performed textual replacements for the attributes you have defined using the same syntax that Ant uses for property expansions - although they are no properties. There seem to be two solutions to this, really use properties or use a different syntax.

We haven't reached a decision yet, but it will almost certainly require a third beta, incompatible with the first two, before we can go to the final release.

Also on the table is local scoping for (special) properties as they are required if you want to replace certain <antcall> use-cases with <macrodef>. For example

  <target name="check-and-fail">
    <available classname="${class}" property="it-is-there"/>
    <fail unless="it-is-there">Couldn't find ${class}</fail>
  </target>
  ...
    <antcall target="check-and-fail">
      <param name="class" value="org.example.Foo"/>
    </antcall>
    <antcall target="check-and-fail">
      <param name="class" value="org.example.Bar"/>
    </antcall>
cannot be replaced with
  <macrodef name="check-and-fail">
    <attribute name="class"/>
    <sequential>
      <available classname="${class}" property="it-is-there"/>
      <fail unless="it-is-there">Couldn't find ${class}</fail>
    </sequential>
  </macrodef>

  <check-and-fail class="org.example.Foo"/>
  <check-and-fail class="org.example.Bar"/>
as the first invocation could set the property and there is no way to change its value or reset it later. Each <antcall> in turn runs in an isolated context and cannot see the properties set by previous invocations.

path: /en/Apache/Ant | #