Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-JSR-2
-
None
-
None
Description
As reported by John Sanda:
I have been experimenting with the new <groovy> Ant task, and some
behavior seems inconsistent with respect to how/where properties are
defined. Consider the following code from my Ant script.
<target name="init-properties">
<property name="testProp1" value="TEST 1"/>
<groovy>
ant.property(name : "testProp2", value : "TEST 2")
ant.echo("${properties.testProp1}") // prints TEST 1
ant.echo("${project.properties.testProp1}") // prints TEST 1
ant.echo("${properties.testProp2}") // prints null
ant.echo("${project.properties.test}") // prints TEST 2
</groovy>
</target>
I expected that defining a property in the <property> tag or in Groovy
script would produce the same results, but that doesn't seem to be the
case. Could this be a bug with AntBuilder or is there something that I
am not understanding? I should also mention that I am using the JSR 2
distribution (groovy-all-1.0-jsr-02.jar).
This happens because project.getProperties() returns only a copy of the actual properties, not the original properties hashtable.
The fix is to put a hashtable wrapper in the binding of the scriptlet to delegate all calls to the original properties hashtable.