Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DRY gradle dependency blocks

Is there a good pattern to reuse dependency blocks in gradle? at the moment there is a lot of repetition ( same blocks in different modules - application / tests / .. ) Is there a way to define these dependencies in a central place and reuse them in the modules?

like image 299
ligi Avatar asked Jan 27 '15 10:01

ligi


1 Answers

You can group dependencies into a list for instance and the pass this list for given configuration:

apply plugin: 'java'

repositories {
    mavenCentral()
}

ext.forDI = [
    'com.google.inject:guice:3.0',
    'com.google.guava:guava:18.0'
]

dependencies {
    compile(forDI)
}

This question might be also helpful for you and this as well.

like image 75
Opal Avatar answered Sep 29 '22 15:09

Opal