Nested Ant Properties
Ant doesn’t support nested properties (directly). After some searching I came across this solution. I’m putting it here mainly as a reminder to myself if I ever need to do this gain.
Just to define the problem… say I want to set the version number to be dependent on the project. Naturally you might think to try something like this…
<property name="project.version" value="${${major.project.name}.project.version}"/>
…but it doesn’t work. The solution that does work is the following:
<macrodef name="propertycopy"> <attribute name="name"/> <attribute name="from"/> <sequential> <property name="@{name}" value="${@{from}}"/> </sequential> </macrodef> <property name="project.version.prop" value="${major.project}.project.version"/> <propertycopy name="project.version" from="${project.version.prop}"/>
Ugly, but workable.
u rock