我有许多from/include/exclude
的任务战配置:
task war {
exclude
exclude
...
into ... from ...
into ... from ...
}
我有另一个任务战配置,除了一个exclude
之外是相同的。
我不想复制这些配置。如何重用第一个配置?
答案 0 :(得分:3)
尝试:
ext.sharedCopyConf = { task, to ->
configure(task) {
into to
from 'a'
}
}
task copy1(type: Copy) { t ->
sharedCopyConf(t, 'b')
}
task copy2(type: Copy) { t ->
sharedCopyConf(t, 'c')
}
查看demo。
答案 1 :(得分:0)
ext.sharedWarConfig = { task->
configure(task) {
from ... include ...
}}
task warWithoutFile(type: War) { task ->
sharedWarConfig(task)
exclude ...
}
task warWithFile(type: War) { task -> sharedWarConfig(task) }
jettyRunWar {
dependsOn warWithFile
dependsOn.remove("war")
webApp = warWithFile.archivePath
}