On Tuesday 02 September 2003 16:26, Gus Heck wrote:
> >> <macrodef> follows (I think) the same rules of properties as
> >> <antcall> with
> >> inheritall=yes.
>
> Modeling after antcall...? I am wary of this as antcall is broken at the
> top level.
> http://issues.apache.org/bugzilla/show_bug.cgi?id=22759 I certainly
> havn't looked at macrodef closely enough to know if it will be subject
> to the same problem, but it makes me wonder. It might even be the case
> that antcall should be deprecated and replaced with macrodef if macrodef
> works at the top level and can truely duplicate antcall's functionality.
I meant that on reading DD's e-mail, I realized that the property
expansion was the same as for using antcall.
The <macrodef> code is totally different to <antcall>, and <macrodef> is not
meant to duplicate antcall's functionality - except for the case where
antcall is used as a template. (My build files had a number of such
targets).
However <macrodef> does allow recursive calling so doing:
<macrodef name="bad.recursive">
<sequential>
<bad.recursive/>
</sequential>
</macrodef>
will cause an stack overflow if called.
One can do:
<project default="recursive" xmlns:ac="antlib:net.sf.antcontrib">
<macrodef name="recursive">
<attribute name="t"/>
<sequential>
<echo>Testing [${t}]</echo>
<ac:if>
<equals arg1="${t}" arg2=""/>
<then>
<echo>DONE!</echo>
</then>
<else>
<ac:propertyregex property="x" input="${t}"
regexp="(.*).$" replace="\1"/>
<recursive t="${x}"/>
</else>
</ac:if>
</sequential>
</macrodef>
<target name="recursive">
<recursive t="hello world"/>
</target>
</project>
Giving the result:
recursive:
[echo] Testing [hello world]
[echo] Testing [hello worl]
[echo] Testing [hello wor]
[echo] Testing [hello wo]
[echo] Testing [hello w]
[echo] Testing [hello ]
[echo] Testing [hello]
[echo] Testing [hell]
[echo] Testing [hel]
[echo] Testing [he]
[echo] Testing [h]
[echo] Testing []
[echo] DONE!
Peter
Note: I am not saying that one should do the above.., it is just
the first example that came into my head.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]