Today while scripting my Dopus Ant files I came across a problem with nested properties.
Something of the sort ${document.${input.file}.type}.
Turns out that Ant cannot do this by default. Yet I found a blog entry that explains how it can be done with newer versions of Ant (those that support macros). I adapted the solution a little bit with the following result:
<!– Needed to resolve a nested property like ${document.${input.file}.type} –>
<macrodef name="resolveProperty">
<attribute name="property" />
<attribute name="value" />
<sequential>
<property name="tmp1.@{property}" value="document.@{value}.type" />
<resolveProperty2 property="@{property}" value="${tmp1.@{property}}" />
</sequential>
</macrodef><macrodef name="resolveProperty2">
<attribute name="property" />
<attribute name="value" />
<sequential>
<property name="@{property}" value="${@{value}}" />
</sequential>
</macrodef>
Now I can set my property like so:
<resolveProperty property="document.calculated.type" value="${project.input.file}" />
which effectively sets document.calculated.type=${document.${project.input.file}.type}.
Nice.

I am Torsten Uhlmann, and AGYNAMIX is my software company.
{ 5 comments… read them below or add one }
thx, this was very helpfully.
Thanks a lot!
I doesn’t fit my needs, but the following works great!
at build properties:
OLDPROP=AB
ABCD=itworks
at build.xml:
at log:
[echo] itworks
–bentzy
at build.xml:
this site deleted my sample – you have to use propertycopy ant-contrib task