Require dependency on s-b-dependencies to use its constraints

Previously, Spring Boot's modules published Gradle Module Metadata
(GMM) the declared a platform dependency on spring-boot-dependencies.
This provided versions for each module's own dependencies but also had
they unwanted side-effect of pulling in spring-boot-dependencies
constraints which would influence the version of other dependencies
declared in the same configuration. This was undesirable as users
should be able to opt in to this level of dependency management, either
by using the dependency management plugin or by using Gradle's built-in
support via a platform dependency on spring-boot-dependencies.

This commit reworks how Spring Boot's build uses
spring-boot-dependencies and spring-boot-parent to provide its own
dependency management. Configurations that aren't seen by consumers are
configured to extend a dependencyManagement configuration that has an
enforced platform dependency on spring-boot-parent. This enforces
spring-boot-parent's version constraints on Spring Boot's build without
making them visible to consumers. To ensure that the versions that
Spring Boot has been built against are visible to consumers, the
Maven publication that produces pom files and GMM for the published
modules is configured to use the resolved versions from the module's
runtime classpath.

Fixes gh-21911
This commit is contained in:
Andy Wilkinson
2020-06-15 20:51:51 +01:00
parent e30b8bf742
commit 0de466e06e
92 changed files with 122 additions and 194 deletions

View File

@@ -6,6 +6,12 @@ plugins {
description = "Spring Boot Deployment Tests"
configurations {
providedRuntime {
extendsFrom dependencyManagement
}
}
dependencies {
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) {
exclude group: "org.hibernate.validator"

View File

@@ -6,7 +6,9 @@ plugins {
description = "Spring Boot Ant smoke test"
configurations {
antDependencies
antDependencies {
extendsFrom dependencyManagement
}
testRepository
}
@@ -31,7 +33,6 @@ dependencies {
testRepository(project(path: ":spring-boot-project:spring-boot-tools:spring-boot-loader", configuration: "mavenRepository"))
testRepository(project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter", configuration: "mavenRepository"))
testImplementation(platform(project(":spring-boot-project:spring-boot-dependencies")))
testImplementation(project(path: ":spring-boot-project:spring-boot-tools:spring-boot-loader-tools"))
testImplementation("org.assertj:assertj-core")
testImplementation("org.junit.jupiter:junit-jupiter")

View File

@@ -1,7 +1,6 @@
plugins {
id "java"
id "org.springframework.boot.conventions"
id "org.springframework.boot.internal-dependency-management"
}
description = "Spring Boot Atmosphere smoke test"

View File

@@ -6,7 +6,6 @@ plugins {
description = "Spring Boot Data R2DBC with Flyway smoke test"
dependencies {
implementation(platform(project(":spring-boot-project:spring-boot-parent")))
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-r2dbc"))
runtimeOnly("io.r2dbc:r2dbc-postgresql")

View File

@@ -6,7 +6,6 @@ plugins {
description = "Spring Boot Data R2DBC with Liquibase smoke test"
dependencies {
implementation(platform(project(":spring-boot-project:spring-boot-parent")))
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-r2dbc"))
runtimeOnly("io.r2dbc:r2dbc-postgresql")

View File

@@ -5,6 +5,12 @@ plugins {
description = "Spring Boot Jetty JSP smoke test"
configurations {
providedRuntime {
extendsFrom dependencyManagement
}
}
dependencies {
compileOnly("jakarta.servlet:jakarta.servlet-api")
compileOnly(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-jetty"))
@@ -13,7 +19,6 @@ dependencies {
exclude module: "spring-boot-starter-tomcat"
}
providedRuntime(platform(project(":spring-boot-project:spring-boot-dependencies")))
providedRuntime("org.eclipse.jetty:apache-jsp") {
exclude group: "javax.annotation", module: "javax.annotation-api"
}

View File

@@ -1,11 +1,11 @@
plugins {
id "java"
// id "org.springframework.boot.conventions"
}
description = "Spring Boot TestNG smoke test"
dependencies {
implementation(platform(project(":spring-boot-project:spring-boot-dependencies")))
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter"))
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-tomcat"))
implementation("org.springframework:spring-webmvc")

View File

@@ -5,6 +5,12 @@ plugins {
description = "Spring Boot Tomcat JSP smoke test"
configurations {
providedRuntime {
extendsFrom dependencyManagement
}
}
dependencies {
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web"))

View File

@@ -5,6 +5,12 @@ plugins {
description = "Spring Boot traditional deployment smoke test"
configurations {
providedRuntime {
extendsFrom dependencyManagement
}
}
dependencies {
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter"))
implementation("org.springframework:spring-webmvc")

View File

@@ -5,12 +5,17 @@ plugins {
description = "Spring Boot war smoke test"
configurations {
providedCompile {
extendsFrom dependencyManagement
}
}
dependencies {
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) {
exclude module: "spring-boot-starter-tomcat"
}
providedCompile(platform(project(":spring-boot-project:spring-boot-dependencies")))
providedCompile("jakarta.servlet:jakarta.servlet-api")
testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))

View File

@@ -5,6 +5,12 @@ plugins {
description = "Spring Boot web JSP smoke test"
configurations {
providedRuntime {
extendsFrom dependencyManagement
}
}
dependencies {
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web"))

View File

@@ -5,6 +5,12 @@ plugins {
description = "Spring Boot web static smoke test"
configurations {
providedRuntime {
extendsFrom dependencyManagement
}
}
dependencies {
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web"))