有没有办法在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中的任务继承任务
答案 0 :(得分:1)
如果propGroup
被定义为地图,它将起作用:
def propGroup = [
options: [
fork: true,
forkOptions: [
executable: true
]
]
]
然后executable
可以是例如简称:
propGroup.options.forkOptions.executable