Do not publish the Spring Boot BOM to consumers (#194) - #198
Open
JangHyeok2909 wants to merge 1 commit into
Open
Do not publish the Spring Boot BOM to consumers (#194)#198JangHyeok2909 wants to merge 1 commit into
JangHyeok2909 wants to merge 1 commit into
Conversation
Declare the Spring Boot modules as compileOnly and keep the BOM only on configurations that are not published, so that neither the BOM nor the Spring Boot dependencies end up in the published variants. Fixes gavlyukovskiy#194
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #194
The Spring Boot BOM is currently declared with
implementation(platform(...)). Sinceimplementationis part of the publishedruntimeElementsvariant, the BOM is propagated to consumers.As a result, every consumer that resolves dependencies through Gradle metadata inherits Spring Boot's entire dependency management. In #194, an application on Spring Boot 3.4.5 had its Prometheus dependencies upgraded by the 3.5.7 BOM shipped with this library, which failed at runtime with
NoSuchMethodError.However,
spring-boot,spring-boot-autoconfigureandspring-boot-jdbcare declared without a version and take it from the BOM, so removing only the platform declaration makes the publication invalid.The Spring Boot modules are therefore declared as
compileOnly, and the BOM is kept only on configurations that are not published (compileOnly,annotationProcessor,testImplementation). Version alignment inside the build is unchanged, and nothing Spring Boot related is published anymore. Note that this is a behaviour change: the published artifacts no longer carry any Spring Boot dependency.This is the same approach used by
opentelemetry-spring-boot-starterandresilience4j-spring-boot3. Anything using this library is a Spring Boot application and always brings its own Spring Boot, so not publishing the BOM is the more appropriate behaviour.Below is the result observed from a consumer on Spring Boot 4.0.0, while this library is built against 4.0.6.
spring-bootis selected as 4.0.0, the version declared by the consumer, and 4.0.6 does not appear anywhere in the runtime graph.Verification
./gradlew buildpasses, including the three sample applications, which consume the artifacts published to mavenLocal..modulenor the.pomof the autoconfigure module and the starters contains a platform dependency.