Spring Boot comes with its own Gradle plugin. One of the features that this plugin offers is automatic dependency version resolution. Basically, it allows developer to omit version and let build process to figure out which version is the best.
However nice, this is just one of the features of Spring Boot Gradle plugin. If you do not want the others, you would need to endeavour to disable them
individually with countless distTar.enabled
, startScripts.enabled
and the like.
Fortunately, this feature is available on its own. It is documented in Spring Docs, but not highlighted as much as it should have been.
Here is how you can enable just the automatic version resolution:
plugins {
id "io.spring.dependency-management" version "0.5.4.RELEASE"
}
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-starter-parent:${springBootVersion}"
}
generatedPomCustomization.enabled = false // Optional, of course
}
This way you will get just the automatic version resolution without anything else. You can define your dependencies like this:
dependencies {
compile 'org.springframework:spring-web'
compile 'org.springframework.security:spring-security-core'
}
But it could get even lighter. If you have some tool that does not like partially defined artifacts, you could go one step further:
dependencies {
compile 'org.springframework:spring-web:' +
dependencyManagement.managedVersions['org.springframework:spring-web']
}
This way your dependency will be indistinguishable from a case when you manually typed in the version for the spring-web. This should work with any gradle tool.
And of course, if you like the way features are separated in Spring Framework, you may want to star out the repository: https://github.com/spring-gradle-plugins/dependency-management-plugin