有办法在Gradle中重用属性组吗?
看起来像:
def propGroup = [
options.fork = true
options.forkOptions.executable = ...
]
task compileThis(type:JavaCompile) {
options.fork = propGroup.options.fork
options.forkOptions.setExecutable(propGroup.options.forkOptions.executable)
destinationDir = file(xxx)
}
task compileThat(type:JavaCompile) {
options.fork = propGroup.options.fork
options.forkOptions.setExecutable(propGroup.options.forkOptions.executable)
destinationDir = file(yyy)
}
在Java中,这将是继承,但不能从Gradle 中的任务继承任务
如果propGroup
被定义为映射,它将起作用:
def propGroup = [
options: [
fork: true,
forkOptions: [
executable: true
]
]
]
则executable
可以例如被称为:
propGroup.options.forkOptions.executable