In Maven there is a very useful feature when you can define a dependency in the section of the parent POM, and reference that depen
io.spring.gradle:dependency-management-plugin plugin has problems with new Gradle 3.x series but stable for 2.x series. For reference look to bug report Drop support for Gradle 3 #115
In case of Spring (main promoter of BOM usage) you may end with:
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:1.0.0.RELEASE'
}
}
repositories {
mavenLocal()
jcenter()
}
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
dependencyManagement {
imports {
mavenBom 'io.spring.platform:platform-bom:Athens-SR3'
}
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
testCompile 'org.springframework.boot:spring-boot-starter-test'
}
Note that io.spring.platform:platform-bom have org.springframework.boot:spring-boot-starter-parent as parent so it is compatable with Spring Boot
You can verify actual dependency resolution via:
$ gradle dependencies
$ gradle dependencies --configuration compile
$ gradle dependencies -p $SUBPROJ
$ gradle buildEnvironment
$ gradle buildEnvironment -p $SUBPROJ
or with task:
task showMeCache {
configurations.compile.each { println it }
}
Read official Soring blog post Better dependency management for Gradle to understand the reason of introducing io.spring.gradle:dependency-management-plugin.