2
我有很多from/include/exclude
任务战争配置:如何在Gradle中重用任务配置?
task war {
exclude
exclude
...
into ... from ...
into ... from ...
}
我还有一个任务战争配置,它只是一个exclude
相同。 我不想重复这些配置。我怎样才能重用第一个配置?
我有很多from/include/exclude
任务战争配置:如何在Gradle中重用任务配置?
task war {
exclude
exclude
...
into ... from ...
into ... from ...
}
我还有一个任务战争配置,它只是一个exclude
相同。 我不想重复这些配置。我怎样才能重用第一个配置?
尝试:
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。
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
}