What is the best way to do dependency management like in Maven <dependencyManagement> tag ?
I did some research online and found out there are a few options:
Gradle configuration resolutionStrategy to force a version
configurations.all {
resolutionStrategy {
force 'com.google.guava:guava:14.0.1'
force 'com.google.guava:guava-gwt:14.0.1'
}
}
Use Gradle's native support for importing BOMs:
From the docs here
dependencies {
// import a BOM
implementation(platform("org.springframework.boot:spring-boot-dependencies:2.1.7.RELEASE"))
// define dependencies without versions
implementation("com.google.code.gson:gson")
implementation("dom4j:dom4j")
// import a BOM for test dependencies
testImplementation(platform("org.junit:junit-bom:5.5.1"))
// define dependency without versions
testImplementation("org.junit.jupiter:junit-jupiter")
}
I recommend watching Managing Dependencies for Spring Projects with Gradle by Jenn Strater and Andy Wilkinson to get some background as to why Spring's dependency management plugin exist and where the plugin itself and Gradle is going.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With