Question

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?

Was it helpful?

Solution

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'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top