I was working on an Ant script (yes, I am using maven2 too for other projects, but in this case I just want to use plain vanilla Ant script) and along the way came upon this need to change an Ant property after it has been initialized.
Did a bit of googling and came upon this forum discussion. Not a very bright and encouraging note at the end - essence being "No; property values, once set, cannot be changed. Attempts to do so will fail silently."
Well, guess what? I am not the kind who give up that easily.
Here are the steps (for contribution back to the community) to change an Ant property after it have been initiatlized. Snaplets of code for illustration purpose only.
OK, now that we have covered the basics, here goes:
<project name="myProject" default="myTarget">
<property name="message" value="Hello, me!"/>
myProject.setProperty("message", "Hello world!");
The portion of code that changed the property value is highlighted. The output should be similar to this:
[echo] Hello, me!
[echo] Hello world!
Total time: 0 seconds
Never give up so easily in life.... that's the lesson. Have fun!