Is there a simple way of taking the value of a property and then copy it to another property with certain characters replaced?
Say propA=This is a value
. I want to replace all the spaces in it into underscores, resulting in propB=This_is_a_value
.
Here is the solution without scripting and no external jars like ant-conrib:
The trick is to use ANT's resources:
<loadresource property="propB">
<propertyresource name="propA"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replacestring from=" " to="_"/>
</tokenfilter>
</filterchain>
</loadresource>
This one will replace all " " in propA by "_" and place the result in propB. "filetokenizer" treats the whole input stream (our property) as one token and appies the string replacement on it.
You can do other fancy transformations using other tokenfilters: http://ant.apache.org/manual/Types/filterchain.html