我有以下内容:
test {
// bunch of common config stuff
// some config stuff specific to `test`
}
task integrationTest(type: Test) {
// bunch of common config stuff
// some config stuff specific to `integrationTest`
}
如何避免重复使用常见的配置内容?
答案 0 :(得分:4)
tasks.withType(Test) {
// common stuff
}
test { ... }
task integrationTest(type: Test) { ... }
答案 1 :(得分:-1)
您可以使用以下方法:http://www.gradle.org/docs/current/userguide/userguide_single.html
test {
config()
// some config stuff specific to `test`
}
task integrationTest(type: Test) {
config()
// some config stuff specific to `integrationTest`
}
void config() {
// bunch of common config stuff
}