Typically, the properties in ant are immutable after installation. With Ant addon Flaka you can change or overwrite existing properties - even custom properties (those properties that are set using the command line -Dkey = value), i.e. create a macro definition and use it as follows:
<project name="demo" xmlns:fl="antlib:it.haefelinger.flaka"> <property name="foo" value="bar"/> <macrodef name="createproperty"> <attribute name="outproperty"/> <attribute name="input"/> <sequential> <fl:let> @{outproperty} ::= '@{input}'</fl:let> </sequential> </macrodef> <createproperty input="${foo}bar" outproperty="fooo"/> <echo>$${fooo} => ${fooo}</echo> <echo>1. $${foo} => ${foo}</echo> <createproperty input="foo${foo}" outproperty="foo"/> <echo>2. $${foo} => ${foo}</echo> </project>
exit
[echo] ${fooo} => barbar [echo] 1. ${foo} => bar [echo] 2. ${foo} => foobar
alternatively you can use some scripting language (Groovy, Javascript, JRuby ..) and use ant api:
project.setProperty(String name, String value)
to overwrite the property.
Rebse source share