spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.95k stars 40.65k forks source link

Cross-reference Dedicated Spring Boot BOM for Consistent Resolution #32412

Open Fleshgrinder opened 2 years ago

Fleshgrinder commented 2 years ago

All Spring Boot (actually all Spring projects, but let us start with Boot) modules should be collected in a dedicated Spring Boot BOM that is then cross-references by every module. This would in turn ensure consistent resolution of all dependencies within a dependency tree. Well, at least on Gradle. According to @wilkinsona this does not work in Maven, I do not know, but even if it is Gradle only it is providing substantial value.

Screenshot 2022-09-16 at 22 16 22

This screenshot illustrates consistent resolution of Jackson dependencies. This is made possible by the Jackson developers because they cross-reference their own BOM in every module of theirs, e.g.:

https://github.com/FasterXML/jackson-annotations/blob/082ee2812f0a7019516181947e591d8ed624425a/pom.xml#L129-L137

The same is possible in Gradle, example build setup:

project(":bom") {
    apply<JavaPlatformPlugin>()
    dependencies {
        constraints {
            api(project(":a"))
            api(project(":b"))
        }
    }
}

project(":a") {
    apply<JavaLibraryPlugin>()
    dependencies {
        api(platform(project(":bom")))
    }
}

project(":b") {
    apply<JavaLibraryPlugin>()
    dependencies {
        api(platform(project(":bom")))
    }
}

I am happy to help with this if there is interest.

wakingrufus commented 2 years ago

I think this request also implies the existence of a spring boot bom, similar to the spring framework bom (https://mvnrepository.com/artifact/org.springframework/spring-framework-bom) which only references the spring boot modules, and not the dependencies. This would be a useful artifact to have, even without the "reference" requirement from the original request here.