Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle configuration inheritance

I have multiple dependencies inside a gradle file and I introduced a new build variant call "apple". But I don't want to copy and paste as the following.

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"    
}

Is there a way I can say appleCompile depends on debugCompile?

like image 497
Rubin Yoo Avatar asked Oct 19 '25 12:10

Rubin Yoo


1 Answers

You can declare a new configuration:

configurations {
    [debugCompile, appleCompile].each { it.extendsFrom commonCompile }
}

Now commonCompile configuration will apply dependencies for both debug and apple configurations, so you don't need to specify those twice.

dependencies {
    commonCompile "com.android:libraryA:1.0.0"    
    commonCompile "com.android:libraryB:1.0.0"    
    commonCompile "com.android:libraryC:1.0.0"    
}
like image 94
azizbekian Avatar answered Oct 21 '25 14:10

azizbekian