0

I am writing a task with gant and I am getting struggled with the task xmlProperty. I have this example xml file:

<root>
    <properties>
        <foo>bar</foo>
    </properties>
</root>

and when I do:

ant.xmlproperty(file:"myFile.xml")
println "${root.properties.foo}"

nothing is printed. Any idea what I am doing wrong?

Fran García
  • 2,011
  • 16
  • 24
  • Not sure (hence the comment), but does `println ant.property( name:'someName', value:'${root.properties.foo}' )` work for you? – tim_yates Apr 28 '14 at 11:23
  • Yes, it works @tim_yates! Not sure why it is not working with double quotes, which I tried before. Thanks! – Fran García Apr 28 '14 at 11:28
  • Ahhh, when you use double quotes, Groovy jumps in and tries to evaluate it as a Groovy String before passing it to antbuilder – tim_yates Apr 28 '14 at 11:30

1 Answers1

1

xmlproperty loads the file in to Ant properties, not Groovy variables, so you need to access them via project.properties on the AntBuilder instance:

println ant.project.properties.'root.properties.foo'
Ian Roberts
  • 120,891
  • 16
  • 170
  • 183