【发布时间】:2017-06-27 19:42:09
【问题描述】:
在 Gradle 中,我们可以像下面这样定义和访问变量吗?在范围(命名空间)内定义变量的更方便的方法。
foo {
bar1 {
variable1 = 'hello';
variable2 = 'hello2';
}
bar2 {
variable1 = 'hello';
variable2 = 'hello2';
}
}
println foo.bar1.variable1
println foo.bar2.variable2
或者需要地图
foo = [bar1 : [variable1 : 'hello',
variable2 : 'hello2'
],
bar2 : [variable1 : 'hello',
variable2 : 'hello2'
]
]
【问题讨论】:
标签: variables dictionary gradle groovy scope