Is there a way to override a macro defined from a library I cannot
control, my goal is to provide a local implementation, but not have to
change all the callers.
I'm stuck on Ant 1.7.0, and cannot update.
How could I "fake out" a scoping mechanism to accomplish something like:
<super.macroImplementation/> or <project[@name].macroImplemenation/>
I tried using <presetdef/> to "override" the macro, but I can't figure
out how to invoke the original macro of the same name. I could
redefine the macro from the library in my local ant script, but I
don't want to open a possibility that my local implementation could
get out of sync with the one from the provided library.
Another way to express what I need is the macro equivalent of target
overriding, which is accomplished with the code snip below, but I need
it for <macrodef/>!
common.xml:
<project name="common_library">
<target name="stuff">
<!-- run stuff from common library -->
</target>
</project>
build.xml:
<project name="myBuild">
<import file="common.xml" />
<target name="stuff" depends="mystuff_first, common_library.stuff"
/>
<!-- henceforth target="stuff" is *my* implementation -->
</project>
But what if its a macro (or scriptdef)? In principle here's what I was
hoping could
work, but it doesn't, so that's why I'm asking:
common.xml:
<project name="common_library">
<macrodef name="routine">
<attribute name="arg1" />
<attribute name="arg2" />
<sequential>
<!-- macro definition from common library -->
</sequential>
</target>
</project>
build.xml:
<project name="myBuild">
<import file="common.xml" />
<presetdef name="routine">
<local_routine/>
</presetdef>
<macrodef name="local_routine">
<attribute name="arg1" />
<attribute name="arg2" />
<sequential>
<!-- add some logic here... -->
<common_library.routine arg1="@{arg1} arg2="@{arg2}" />
</sequential>
</macrodef>
<!-- henceforth <routine/> is *my* implementation -->
</project>
Any ideas would be much appreciated. Thanks.
--Cyril