Based on your comments, perhaps this will help.
You can define a target that sets the widget.base
property, and in turn calls another target the name of which is passed as a parameter. The value of widget.base
will be recalculated within each call to the wrapper.
The example below sets up two nested targets, the first calls a macrodef as in your question. The second simply invokes the tasks in the target directly. The main target calls each a couple of times to test the substitution.
<property name="platform" value="foo" />
<property name="resolution" value="bar" />
<property name="widget.name" value="bibble" />
<property name="build.dir" value="boo" />
<property name="build.timestamp" value ="1234"/>
<!--sets the property on each call then calls the target with the passed name -->
<target name="wrapper">
<property name="widget.base" value="${build.dir}/widget/${platform}/${resolution}/${widget.name}" />
<antcall target="${nestedTarget}"/>
</target>
<target name="nestedTarget1">
<setBuildstamp widgetBase="${widget.base}" buildTimestamp="${build.timestamp}"/>
</target>
<target name="nestedTarget2">
<echo>"different/${widget.base}/Contents/Javascript/views/sidebar/DevSettingsView.js"
token="%%%BUILD_TIMESTAMP%%%" value="${build.timestamp}"</echo>
</target>
<macrodef name="setBuildstamp">
<attribute name="widgetBase" />
<attribute name="buildTimestamp" />
<sequential>
<echo>"@{widgetBase}/Contents/Javascript/views/sidebar/DevSettingsView.js"
token="%%%BUILD_TIMESTAMP%%%" value="@{buildTimestamp}"</echo>
</sequential>
</macrodef>
<target name="test">
<antcall target="wrapper">
<param name="platform" value="${platform}"/>
<param name="resolution" value="${resolution}"/>
<param name="nestedTarget" value="nestedTarget1"/>
</antcall>
<antcall target="wrapper">
<param name="platform" value="starsky"/>
<param name="resolution" value="hutch"/>
<param name="nestedTarget" value="nestedTarget1"/>
</antcall>
<antcall target="wrapper">
<param name="platform" value="fizz"/>
<param name="resolution" value="buzz"/>
<param name="nestedTarget" value="nestedTarget2"/>
</antcall>
<antcall target="wrapper">
<param name="platform" value="jim"/>
<param name="resolution" value="joe"/>
<param name="nestedTarget" value="nestedTarget2"/>
</antcall>
</target>
The output of running this script is:
test:
wrapper:
nestedTarget1:
[echo] "boo/widget/foo/bar/bibble/Contents/Javascript/views/sidebar/DevSettingsView.js"
[echo] token="%%%BUILD_TIMESTAMP%%%" value="1234"
wrapper:
nestedTarget1:
[echo] "boo/widget/starsky/hutch/bibble/Contents/Javascript/views/sidebar/DevSettingsView.js"
[echo] token="%%%BUILD_TIMESTAMP%%%" value="1234"
wrapper:
nestedTarget2:
[echo] "different/boo/widget/fizz/buzz/bibble/Contents/Javascript/views/sidebar/DevSettingsView.js"
[echo] token="%%%BUILD_TIMESTAMP%%%" value="1234"
wrapper:
nestedTarget2:
[echo] "different/boo/widget/jim/joe/bibble/Contents/Javascript/views/sidebar/DevSettingsView.js"
[echo] token="%%%BUILD_TIMESTAMP%%%" value="1234"
BUILD SUCCESSFUL