Gradle configuration inheritance
I have a few dependencies inside my gradle file and I introduced a new build variant "apple". But I don't want to copy and paste the following data.
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"
}
Can we say which appleCompile
depends on debugCompile
?
+3
source to share
1 answer
You can declare a new configuration:
configurations {
[debugCompile, appleCompile].each { it.extendsFrom commonCompile }
}
The config commonCompile
will now apply the dependencies to the debug
and config apple
so you don't need to specify them twice.
dependencies {
commonCompile "com.android:libraryA:1.0.0"
commonCompile "com.android:libraryB:1.0.0"
commonCompile "com.android:libraryC:1.0.0"
}
+2
source to share