I have an ant file that does the following:
Actually ant properties may be overriden. See the documentation of the property task:
Normally property values can not be changed, once a property is set, most tasks will not allow its value to be modified.
One of the tasks that are able to override the property value is script
. Also any custom task may use this backdoor. Other proposals are in question Ant loadfile override property. This is against the spirit of ant and usually unnecessary. But it's good to know that, because I just had an opposite problem: why the property value changed although it is immutable.
Here is a sample target that uses script task to change the value of a property. It shows the basic methods to work with properties. All methods are described in Ant Api which is not available online. You need to download the Ant Manual. In its api
directory there is the api documentation.
a=${a}
How to easily setup the script
task? Making the script task running with beanshell
language is a bit tricky and non-trivial, but it's explained in this answer. However as Rebse noted, using javascript
language is supported out of the box in jdk 6.