Clayton Walker
07/23/2025, 4:28 PMThomas Broyer
07/23/2025, 4:31 PMenforcedPlatform()
, but DO NOT publish any project using it as enforcement is transitive.
https://docs.gradle.org/current/userguide/platforms.html#sec:enforced-platformClayton Walker
07/23/2025, 4:39 PMClayton Walker
07/23/2025, 4:43 PMimplementation(enforcedPlatform("org.springframework.boot:spring-boot-dependencies:2.7.18"))
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-logging")
implementation("io.github.microutils:kotlin-logging:3.0.5")
// i.e. fixes a bug that's not in the platform, or forcefully downgrades a dependency
implementation("org.slf4j:slf4j-api:2.0.12!!")
then gradle fails with
Execution failed for task ':app:compileJava'.
> Could not resolve all files for configuration ':app:compileClasspath'.
> Could not resolve org.slf4j:slf4j-api:{strictly 2.0.12}.
Required by:
project :app
> Cannot find a version of 'org.slf4j:slf4j-api' that satisfies the version constraints:
Dependency path 'gradle-enforced-platform-testing:app:unspecified' --> 'org.slf4j:slf4j-api:{strictly 2.0.12}'
Constraint path 'gradle-enforced-platform-testing:app:unspecified' --> 'org.springframework.boot:spring-boot-dependencies:2.7.18' (enforced-platform-compile) --> 'org.slf4j:slf4j-api:1.7.36'
Dependency path 'gradle-enforced-platform-testing:app:unspecified' --> 'io.github.microutils:kotlin-logging:3.0.5' (jvmApiElements-published) --> 'io.github.microutils:kotlin-logging-jvm:3.0.5' (jvmApiElements-published) --> 'org.slf4j:slf4j-api:2.0.3'
Dependency path 'gradle-enforced-platform-testing:app:unspecified' --> 'org.springframework.boot:spring-boot-starter-logging:2.7.18' (apiElements) --> 'ch.qos.logback:logback-classic:1.2.12' (compile) --> 'org.slf4j:slf4j-api:1.7.32'
Dependency path 'gradle-enforced-platform-testing:app:unspecified' --> 'org.springframework.boot:spring-boot-starter-logging:2.7.18' (apiElements) --> 'org.apache.logging.log4j:log4j-to-slf4j:2.17.2' (compile) --> 'org.slf4j:slf4j-api:1.7.35'
Dependency path 'gradle-enforced-platform-testing:app:unspecified' --> 'org.springframework.boot:spring-boot-starter-logging:2.7.18' (apiElements) --> 'org.slf4j:jul-to-slf4j:1.7.36' (compile) --> 'org.slf4j:slf4j-api:1.7.36'
Thomas Broyer
07/23/2025, 4:47 PMexclude
, but I have never used enforcedPlatform myself so really can't help further, sorryClayton Walker
07/23/2025, 5:03 PMimplementation(enforcedPlatform("org.springframework.boot:spring-boot-dependencies:2.7.18")) {
(this as ExternalModuleDependency).exclude("org.slf4j", "slf4j-api")
}
Clayton Walker
07/23/2025, 5:03 PMClayton Walker
07/23/2025, 5:05 PMVampire
07/23/2025, 5:40 PMplatform
as also the Spring Boot documentation recommends.
If you "add a dependency that tries to bump lib1 to version2", that means this dependency declares that it needs version 2. Only giving it version 1 is playing Jeopardy, as it clearly told you it needs version 2.