Managing Dependencies for Spring Projects with Gradle by Jenn Strater and Andy Wilkinson
Why Stack Overflow recommends it
Stack Overflow users link it when explaining why to drop the Spring Dependency Management plugin in favour of Gradle's native platform and BOM import support.
Recommended by 2 people across 4 different months, 2019 to 2024.
What it is
A Spring I/O 2019 conference talk by Jenn Strater and Andy Wilkinson on managing dependencies in Spring projects with Gradle. It compares the Spring Dependency Management plugin with Gradle 5's native BOM support and shows how to use the native approach with Spring Boot.
What people said
Strong rec Cisco · 2021-12 · Stack Overflow · on “Gradle ResolutionStrategy in root build.gradle”
The Spring Dependency Management plugin is a bit 'greedy', so you can't exactly mix both styles (Spring/Native Gradle). See this excellent talk: [this video]
Recommends Cisco · 2019-08 · Stack Overflow · on “Is there any replacement of dependencyManagement.importedProperties in Gradle 5?”
Currently no. There are many features that are not yet available. You can plan to see it implemented in later versions of Gradle or more likely an equivalent functionality. See this detailed video below on the comparison of Spring Dependency management and Gradle 5's support for importing BOMs: Managing Dependencies for Spring Projects with Gradle by Jenn Strater and Andy Wilkinson [this video]
Recommends Cisco · 2019-08 · Stack Overflow · on “Gradle dependency management to force version”
Use Gradle's native support for importing BOMs: From the docs here [LINK] 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 [this video] to get some background as to why Spring's dependency management plugin exist and
Recommends Cisco · 2020-02 · Stack Overflow · on “How Gradle BOM import support resolve dependency version added in plugin dynamically?”
Spring's dependency management plugin is a bit heavy handed. It touches all configurations as you can see here [LINK] with the usage of all() call. The native Gradle solution is optimized or "smarter" and only "touches" the configurations it needs to. You can learn more about differences in this [this video] talk. So the solution here is to import the BOM or platform as Gradle calls it for the jooqRuntime configuration. This can either be done in your project: dependencies { "jooqRuntime"(platform("org.springframework.boot:spring-boot-dependencies:2.2.5.RELEASE") } or in the plugin directly (Java example): public class MyCustomPlugin implements Plugin<Project> { @Override public void execute(Proj
Recommends Reed M · 2024-12 · Stack Overflow · on “Is there a spring.dependency-management plugin supported way to require minimum transitive dependency versions without strictly setting them?”
The solution is in fact to just bite the bullet and ditch the spring.dependency-management plugin. Here's [this video] a talk where the guy who wrote it begs people to switch to using gradle platforms (gradle version 5+) because it's just better. The switch is super simple. Just remove the io.spring.dependency-management plugin from the top of the build.gradle, and then replace dependencyManagement { imports { mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}" // or whatever BOM you use } } with dependencies { implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") // or whatever BOM you use } at the top of the dependencies
Cites wakedeer · 2020-02 · Stack Overflow · on “How to define dependency version only once for whole Gradle multi-module project?”
I made a decision to migrate from Dependency Management Plugin [LINK] to Gradle built-in BOM import support [LINK] . Since Gradle built-in BOM import support has better performance [this video] But I run into the issue: I cannot find alternatives for dependency [LINK] and dependencySet [LINK] in native Gradle: dependencyManagement { dependencies { dependency("org.springframework:spring-core:4.0.3.RELEASE") } } //or dependencyManagement { dependencies { dependencySet(group:'org.slf4j', version: '1.7.7') { entry 'slf4j-api' entry 'slf4j-simple' } } } and then I could use dependency without version dependencies { compile 'org.springframework:spring-core' } How can I get the same behavior in naive Gr
Cites Cisco · 2020-07 · Stack Overflow · on “Library version in gradle downgraded”
The Spring Dependency Management plugin is rather heavy handed. If were you build your project with --info or -i , you will see a bunch of these logs: Applying dependency management to configuration 'bootArchives' in project 'demo' Applying dependency management to configuration 'archives' in project 'demo' Applying dependency management to configuration 'default' in project 'demo' Applying dependency management to configuration 'compile' in project 'demo' Applying dependency management to configuration 'implementation' in project 'demo' Applying dependency management to configuration 'runtime' in project 'demo' Applying dependency management to configuration 'compileOnly' in project 'demo'
Cites Cisco · 2021-11 · Stack Overflow · on “How do I exclude a dependency from being pinned by Spring Boot's dependency management plugin?”
A cleaner and more efficient approach would be to use Gradle's platform support [LINK] . So, drop/remove the Spring Dependency Management plugin entirely: import org.springframework.boot.gradle.plugin.SpringBootPlugin; dependencies { implementation(platform(SpringBootPlugin.BOM_COORDINATES)) } Debezium also offers a BOM which you can also import as well: import org.springframework.boot.gradle.plugin.SpringBootPlugin; dependencies { implementation(platform(SpringBootPlugin.BOM_COORDINATES)) implementation(platform("io.debezium:debezium-bom:1.7.1.Final")) } With these changes in place, Gradle's standard dependency resolution [LINK] will be in play. By default, the higher version of two depende