Can Ant properties set via properties file, resolve other properties from properties files?
For example, I can do this:
<property name="prop1" value="in_test_xml1" />
<property name="prop2" value="${prop1}" />
and prop2 becomes "in_test_xml1". That's good.
But in this case, when using an input properties file:
prop1=sample_prop
prop2=${prop1}
prop2 is not set to "sample_prop"
So resolving properties from other properties only seems to work when the property doing the resolving is in the ant file itself.
Is this expected or am i missing something?
Ant does support in-file property expansion, see the Property File section in the manual for the Property task.
The following example shows properties getting resolved:
First properties file:
Second properties file:
Build file:
Output:
Is there another kind of property resolution that is not working for you?
Edit
Following your comment, I now understand that you are using the
-propertyfile
command line option to specify a property file for Ant to load (rather than specifying the file in the buildfile itself, as I did above).I did quick test with this and find that Ant 1.7.1 did not do in-file property expansion on files loaded using that command line option. But Ant 1.8.2 does.
This is Ant Bug 18732. You should be able to resolve by updating your version of Ant.
A simpler solution for this task would be the usage of Ant-contrib Tasks: Propertycopy.
From the manual: