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?

有帮助吗?

解决方案

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'
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top