| Author |
Gradle Dependency Version Control
|
Mike Gage
Greenhorn
Joined: Jan 22, 2002
Posts: 7
|
|
I have become accustomed to working with Maven. Our company is now widely adopting Gradle in place of Maven. One of the features I enjoy in Maven is dependency management in a parent project to control dependency versions in subprojects. I am sure that there is an equivalent mechanism in Gradle. What is the preferred way to do that?
Thank you,
Mike Gage
|
 |
Hubert Klein Ikkink
author
Greenhorn
Joined: Jan 10, 2013
Posts: 13
|
|
Hi Mike,
Gradle allows to simply define variables and assign dependency artefact names to them. You can then use the variable in subprojects or where you want to define dependencies.
For example for a multiproject build file we could have the following build file:
apply plugin: 'java'
def springVersion = '3.2.0.RELEASE'
def springModule = 'org.springframework'
def springLibs = [core: "$springModule:spring-core:$springVersion", test: "$springModule:spring-test:$springVersion"]
def junitLib = "junit:junit:4.10+"
allprojects {
repositories.mavenCentral()
dependencies {
compile springLibs.core
testCompile springLibs.test
}
}
project(':special') {
dependencies {
testCompile junitLib
}
// To remove spring-test dependency
configurations {
testCompile.exclude springLib.test
}
}
|
 |
Mike Gage
Greenhorn
Joined: Jan 22, 2002
Posts: 7
|
|
Very cool!
Thank you.
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: Gradle Dependency Version Control
|
|
|