So the overall problem is this:
We have multiple property files
<property file="prop1"/>
<property file="prop2"/>
prop1 contains a property looking like:
mg.prop = ${mg2.prop}
prop2 contains mg2.prop
mg2.prop = Hello
If they were in the same file and I queried mg.prop, I’d get “Hello” back. Since they are in separate files this does not work (I need to load prop1 before prop2!)
I wrote a custom ant task that does the following:
String resolved = resolveProperty(propertyName);
getProject().setProperty(propertyName, resolved);
If I run
log("Resolved property value = " + getProject().getProperty(propertyName));
Right after, I get the correct value.
However in the Ant script, if I do
<echo message="${mg.prop}"/>
it shows me the original value.
Any thoughts on how to solve this?
Here’s how I ended up resolving this – I turfed the custom ant task.
I ended up concatenating all the properties files into one, in the reverse order of precedence.
So if I wanted properties from 3.properties to override those in 2.properties and 1.properties, I did the following: