我在gradle文件中有多个依赖项,我引入了一个新的构建变体调用“apple”。但我不想复制和粘贴如下。
dependencies {
debugCompile "com.android:libraryA:1.0.0"
debugCompile "com.android:libraryB:1.0.0"
debugCompile "com.android:libraryC:1.0.0"
appleCompile "com.android:libraryA:1.0.0"
appleCompile "com.android:libraryB:1.0.0"
appleCompile "com.android:libraryC:1.0.0"
}
我可以说appleCompile
取决于debugCompile
吗?
答案 0 :(得分:2)
您可以声明新配置:
configurations {
[debugCompile, appleCompile].each { it.extendsFrom commonCompile }
}
现在commonCompile
配置将为debug
和apple
配置应用依赖项,因此您无需指定两次。
dependencies {
commonCompile "com.android:libraryA:1.0.0"
commonCompile "com.android:libraryB:1.0.0"
commonCompile "com.android:libraryC:1.0.0"
}