This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Gradle Dependency Version Control

 
Mike Gage
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
IntelliJ IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very cool!

Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic