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
.
If ant-contrib isn't an option, here's a portable solution for Java 1.6 and later:
Use some external app like sed:
If you run Windows get it googling for "gnuwin32 sed".
The command
s/_/./g
replaces every_
with.
This script goes well under windows. Under linux arg may need quoting.Here's a more generalized version of Uwe Schindler's answer:
You can use a
macrodef
to create a custom task.you can use this as follows:
this will be pretty useful if you are doing this multiple times
In case you want a solution that does use Ant built-ins only, consider this:
Output is
${propB} = "This_is_a_value"