DRY gradle dependency blocks

Is there a good template for reusing dependency blocks in gradle? at the moment there are many repetitions (the 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?

+4
source share
1 answer

You can group dependencies into a list, for example, and pass this list to a 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 can be useful for you and this one .

+4
source

All Articles