Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-964

Can't access dynamicly defined properties from scriptlets in Groovy scriptlets in Ant build files

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-JSR-2
    • Fix Version/s: 1.0-JSR-3
    • Component/s: None
    • Labels:
      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.

        Attachments

          Activity

            People

            • Assignee:
              guillaume Guillaume Sauthier
              Reporter:
              guillaume Guillaume Sauthier
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: