grails - 在GANT中使用xmlProperty任务

标签 grails ant groovy gant

我正在用gant编写任务,而在任务xmlProperty方面遇到了麻烦。我有这个示例xml文件:

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

当我这样做时:
ant.xmlproperty(file:"myFile.xml")
println "${root.properties.foo}"

什么都不会打印。知道我在做什么错吗?

最佳答案

xmlproperty将文件加载到Ant属性中,而不是Groovy变量中,因此您需要通过project.properties实例上的AntBuilder访问它们:

println ant.project.properties.'root.properties.foo'

关于grails - 在GANT中使用xmlProperty任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23339646/

相关文章:

Groovy 代表按预期工作?

grails - Grails remoteLink与<a>

java - Ant 覆盖我的manifest.mf文件

ant - ant build.xml 文件的最佳位置?

java - 获取 Ant 构建错误 : Cannot run program "python"

java - Gradle : Could not find org. codehaus.groovy :groovy:1. 0.0

grails - Grails 3.1.1的Grails渲染插件

json - 从android中的httppost获取参数到grails

grails - 在 Grails 中将 SpringSecurityService 注入(inject) Filter 时为 Null

jenkins - 在 Jenkins 中锁定并行阶段