Skip to content

spring-boot-configuration-metadata leaks enforced dependency constraints into consuming builds #27726

@remal

Description

@remal

A minimal reproducible build.gradle:

apply plugin: 'java'

dependencies {
    testImplementation platform('org.springframework.boot:spring-boot-dependencies:2.5.3')
    constraints {
        testImplementation 'org.mockito:mockito-core:3.11.2'
    }
    
    testImplementation 'org.springframework.boot:spring-boot-properties-migrator'
    testImplementation 'org.mockito:mockito-core'
}

The expected Mockito version in testImplementation configuration is 3.11.2, but I get 3.9.0. However, I can get 3.11.2 version by removing org.springframework.boot:spring-boot-properties-migrator dependency.

 

The bug can be fixed by changing this line:

api(platform(project(path: ":spring-boot-project:spring-boot-parent")))

... to this one:

    api(platform(project(path: ":spring-boot-project:spring-boot-dependencies")))

 

Let me explain why I think it makes sense to change the current behavior.

  1. spring-boot-properties-migrator module depends on spring-boot-configuration-metadata:

    api(project(":spring-boot-project:spring-boot-tools:spring-boot-configuration-metadata"))

  2. spring-boot-configuration-metadata module depends on spring-boot-parent platform:

    api(platform(project(path: ":spring-boot-project:spring-boot-parent")))

  3. spring-boot-parent platform depends on spring-boot-dependencies enforced platform:

    api(enforcedPlatform(project(":spring-boot-project:spring-boot-dependencies")))

  4. Enforcing spring-boot-dependencies platform makes Gradle prioritize its versions over versions defined in dependencies.constraints { ... }, even if the version in constraints is greater than the version in spring-boot-dependencies.

By making spring-boot-configuration-metadata depend on spring-boot-dependencies instead of spring-boot-parent we'll make Spring versions not enforced, and this will allow changing dependency versions in constraints.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions