jjohannes / gradle-project-setup-howto

How to structure a growing Gradle project with smart dependency management?
Apache License 2.0
129 stars 12 forks source link

Question: Spring Boot dependency management plugin #20

Open randyhbh opened 2 weeks ago

randyhbh commented 2 weeks ago

Hi @jjohannes, Thank you for all the effort you have put into this repo and for sharing your knowledge about Gradle through your fantastic compilation of videos on YouTube.

I was reviewing the setup project for Java + Spring Boot that you have shared, and I noticed that the id("io.spring.dependency-management") version "1.1.4" plugin, which provides dependency version resolution for all Spring Boot based projects, was not used.

I am curious to know why you chose not to use this plugin. I would appreciate it if you could share your thoughts on this matter.

jjohannes commented 2 weeks ago

Hi @randyhbh. Thanks for the feedback and the question. 🙏

I think the docs on the id("io.spring.dependency-management") are not very clear on this topic. Since Gradle 6, Gradle fully supports using BOMs directly. Which in most cases makes the plugin obsolete. In special cases it may have some interesting additional functionality. I found this issue comment listing the differences.

I prefer not using the plugin if not specifically needed, because it may have unexpected effects on the resolution result by the way it "forces" all versions of spring-boot-dependencies. But it can be a choice to use the plugin if there is a good reason.

In this example, I do not use it and have this instead in the platform project:

dependencies {
  api(platform("org.springframework.boot:spring-boot-dependencies:2.7.18"))
  // ...
}

Which means that my own platform/BOM extends the spring-boot-dependencies platform/BOM.