From afcc4304818d1a6c7d1388e7a8cfc2799a1c3718 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 11 Jun 2018 15:33:05 +0200 Subject: [PATCH] Remove dependency management noise from POMs Prior to this commit, the generated POMs for Spring Framework modules would contain unneeded/harmful information from the Spring Framework build: 1. The BOM imports applied to each module by the dependency management plugin, for example for Netty or Reactor Netty. Spring should not export that opinion to its POMs. 2. The exclusion of "org.slf4:jcl-over-slf4j" from *all* dependencies, which made the POMs much larger than necessary and suggested to developers that they should exclude it as well when using all those listed dependencies. In fact, only Apache Tiles currently brings that transitively. This commit removes that information from the POMs. The dependencyManagement Gradle plugin is disabled for POM generation and we manually resolve the dependency versions during the generation phase. The Gradle build is streamlined to exclude "org.slf4:jcl-over-slf4j" only when necessary. Issue: SPR-16893 (Cherry-picked from 417354da8a) --- build.gradle | 66 +++++++++++-------- gradle/publish-maven.gradle | 5 ++ spring-core/spring-core.gradle | 6 -- .../spring-framework-bom.gradle | 6 -- spring-messaging/spring-messaging.gradle | 6 -- spring-test/spring-test.gradle | 10 +-- spring-web/spring-web.gradle | 7 -- spring-webflux/spring-webflux.gradle | 6 -- spring-webmvc/spring-webmvc.gradle | 17 ++--- spring-websocket/spring-websocket.gradle | 6 -- 10 files changed, 50 insertions(+), 85 deletions(-) diff --git a/build.gradle b/build.gradle index 8513591b39..c4ae5e0de8 100644 --- a/build.gradle +++ b/build.gradle @@ -35,40 +35,54 @@ ext { moduleProjects = subprojects.findAll { !it.name.equals('spring-build-src') && !it.name.equals('spring-framework-bom') } + + aspectjVersion = "1.8.13" + freemarkerVersion = "2.3.27-incubating" + groovyVersion = "2.4.15" + hsqldbVersion = "2.4.1" + jackson2Version = "2.9.5" + jettyVersion = "9.4.11.v20180605" + junitJupiterVersion = "5.0.3" + junitPlatformVersion = "1.0.3" + junitVintageVersion = "4.12.3" + kotlinVersion = "1.2.41" + log4jVersion = "2.11.0" + nettyVersion = "4.1.25.Final" + reactorVersion = "Bismuth-SR9" + rxjavaVersion = "1.3.8" + rxjavaAdapterVersion = "1.2.1" + rxjava2Version = "2.1.14" + slf4jVersion = "1.7.25" // spring-jcl + consistent 3rd party deps + tiles3Version = "3.0.8" + tomcatVersion = "8.5.31" + undertowVersion = "1.4.25.Final" + + gradleScriptDir = "${rootProject.projectDir}/gradle" + withoutJclOverSlf4J = { + exclude group: "org.slf4j", module: "jcl-over-slf4j" + } } configure(allprojects) { project -> group = "org.springframework" version = qualifyVersionIfNecessary(version) - ext.aspectjVersion = "1.8.13" - ext.freemarkerVersion = "2.3.27-incubating" - ext.groovyVersion = "2.4.15" - ext.hsqldbVersion = "2.4.1" - ext.jackson2Version = "2.9.5" - ext.jettyVersion = "9.4.11.v20180605" - ext.junitJupiterVersion = "5.0.3" - ext.junitPlatformVersion = "1.0.3" - ext.junitVintageVersion = "4.12.3" - ext.kotlinVersion = "1.2.41" - ext.log4jVersion = "2.11.0" - ext.nettyVersion = "4.1.25.Final" - ext.reactorVersion = "Bismuth-SR9" - ext.rxjavaVersion = "1.3.8" - ext.rxjavaAdapterVersion = "1.2.1" - ext.rxjava2Version = "2.1.14" - ext.slf4jVersion = "1.7.25" // spring-jcl + consistent 3rd party deps - ext.tiles3Version = "3.0.8" - ext.tomcatVersion = "8.5.31" - ext.undertowVersion = "1.4.25.Final" - - ext.gradleScriptDir = "${rootProject.projectDir}/gradle" - apply plugin: "propdeps" apply plugin: "java" apply plugin: "test-source-set-dependencies" + apply plugin: "io.spring.dependency-management" apply from: "${gradleScriptDir}/ide.gradle" + dependencyManagement { + resolutionStrategy { + cacheChangingModulesFor 0, 'seconds' + } + applyMavenExclusions = false + generatedPomCustomization { + enabled = false + } + } + apply plugin: "kotlin" compileKotlin { kotlinOptions { @@ -96,7 +110,6 @@ configure(allprojects) { project -> } } - exclude group: "org.slf4j", module: "jcl-over-slf4j" } def commonCompilerArgs = @@ -238,7 +251,6 @@ configure(rootProject) { description = "Spring Framework" apply plugin: "groovy" - apply plugin: "io.spring.dependency-management" apply from: "${gradleScriptDir}/jdiff.gradle" apply from: "${gradleScriptDir}/docs.gradle" @@ -246,10 +258,6 @@ configure(rootProject) { imports { mavenBom "io.projectreactor:reactor-bom:${reactorVersion}" } - resolutionStrategy { - cacheChangingModulesFor 0, 'seconds' - } - applyMavenExclusions = false } // don't publish the default jar for the root project diff --git a/gradle/publish-maven.gradle b/gradle/publish-maven.gradle index eff54387f6..249d23f4ce 100644 --- a/gradle/publish-maven.gradle +++ b/gradle/publish-maven.gradle @@ -18,6 +18,11 @@ def customizePom(pom, gradleProject) { "$dep.scope:$dep.groupId:$dep.artifactId" } + def managedVersions = dependencyManagement.managedVersions + generatedPom.dependencies.findAll{dep -> !dep.version }.each { dep -> + dep.version = managedVersions["${dep.groupId}:${dep.artifactId}"] + } + // add all items necessary for maven central publication generatedPom.project { name = gradleProject.description diff --git a/spring-core/spring-core.gradle b/spring-core/spring-core.gradle index 03ac8ee44b..181c0ba10a 100644 --- a/spring-core/spring-core.gradle +++ b/spring-core/spring-core.gradle @@ -1,16 +1,10 @@ description = "Spring Core" -apply plugin: "io.spring.dependency-management" - dependencyManagement { imports { mavenBom "io.projectreactor:reactor-bom:${reactorVersion}" mavenBom "io.netty:netty-bom:${nettyVersion}" } - resolutionStrategy { - cacheChangingModulesFor 0, 'seconds' - } - applyMavenExclusions = false } // As of Spring 4.0.3, spring-core includes asm 5.x and repackages cglib 3.2, inlining diff --git a/spring-framework-bom/spring-framework-bom.gradle b/spring-framework-bom/spring-framework-bom.gradle index 4076574756..d748629ca4 100644 --- a/spring-framework-bom/spring-framework-bom.gradle +++ b/spring-framework-bom/spring-framework-bom.gradle @@ -1,11 +1,5 @@ description = "Spring Framework (Bill of Materials)" -dependencyManagement { - generatedPomCustomization { - enabled = false - } -} - configurations.archives.artifacts.clear() artifacts { // work around GRADLE-2406 by attaching text artifact diff --git a/spring-messaging/spring-messaging.gradle b/spring-messaging/spring-messaging.gradle index 97b28b4656..af60dae44a 100644 --- a/spring-messaging/spring-messaging.gradle +++ b/spring-messaging/spring-messaging.gradle @@ -1,16 +1,10 @@ description = "Spring Messaging" -apply plugin: "io.spring.dependency-management" - dependencyManagement { imports { mavenBom "io.projectreactor:reactor-bom:${reactorVersion}" mavenBom "io.netty:netty-bom:${nettyVersion}" } - resolutionStrategy { - cacheChangingModulesFor 0, 'seconds' - } - applyMavenExclusions = false } dependencies { diff --git a/spring-test/spring-test.gradle b/spring-test/spring-test.gradle index 6165c49111..9c8994f6fd 100644 --- a/spring-test/spring-test.gradle +++ b/spring-test/spring-test.gradle @@ -1,16 +1,10 @@ description = "Spring TestContext Framework" -apply plugin: "io.spring.dependency-management" - dependencyManagement { imports { mavenBom "io.projectreactor:reactor-bom:${reactorVersion}" mavenBom "io.netty:netty-bom:${nettyVersion}" } - resolutionStrategy { - cacheChangingModulesFor 0, 'seconds' - } - applyMavenExclusions = false } dependencies { @@ -74,8 +68,8 @@ dependencies { testCompile("com.thoughtworks.xstream:xstream:1.4.10") testCompile("com.rometools:rome:1.9.0") testCompile("org.apache.tiles:tiles-api:${tiles3Version}") - testCompile("org.apache.tiles:tiles-core:${tiles3Version}") - testCompile("org.apache.tiles:tiles-servlet:${tiles3Version}") + testCompile("org.apache.tiles:tiles-core:${tiles3Version}", withoutJclOverSlf4J) + testCompile("org.apache.tiles:tiles-servlet:${tiles3Version}", withoutJclOverSlf4J) testCompile("org.hsqldb:hsqldb:${hsqldbVersion}") testCompile("org.apache.httpcomponents:httpclient:4.5.5") { exclude group: "commons-logging", module: "commons-logging" diff --git a/spring-web/spring-web.gradle b/spring-web/spring-web.gradle index a034b9c2b1..106d91387f 100644 --- a/spring-web/spring-web.gradle +++ b/spring-web/spring-web.gradle @@ -1,17 +1,10 @@ description = "Spring Web" -apply plugin: "groovy" -apply plugin: "io.spring.dependency-management" - dependencyManagement { imports { mavenBom "io.projectreactor:reactor-bom:${reactorVersion}" mavenBom "io.netty:netty-bom:${nettyVersion}" } - resolutionStrategy { - cacheChangingModulesFor 0, 'seconds' - } - applyMavenExclusions = false } dependencies { diff --git a/spring-webflux/spring-webflux.gradle b/spring-webflux/spring-webflux.gradle index 73b511a896..ded409908f 100644 --- a/spring-webflux/spring-webflux.gradle +++ b/spring-webflux/spring-webflux.gradle @@ -1,16 +1,10 @@ description = "Spring WebFlux" -apply plugin: "io.spring.dependency-management" - dependencyManagement { imports { mavenBom "io.projectreactor:reactor-bom:${reactorVersion}" mavenBom "io.netty:netty-bom:${nettyVersion}" } - resolutionStrategy { - cacheChangingModulesFor 0, 'seconds' - } - applyMavenExclusions = false } dependencies { diff --git a/spring-webmvc/spring-webmvc.gradle b/spring-webmvc/spring-webmvc.gradle index 20513514f5..94445e7680 100644 --- a/spring-webmvc/spring-webmvc.gradle +++ b/spring-webmvc/spring-webmvc.gradle @@ -1,15 +1,9 @@ description = "Spring Web MVC" -apply plugin: "io.spring.dependency-management" - dependencyManagement { imports { mavenBom "io.projectreactor:reactor-bom:${reactorVersion}" } - resolutionStrategy { - cacheChangingModulesFor 0, 'seconds' - } - applyMavenExclusions = false } dependencies { @@ -35,13 +29,14 @@ dependencies { optional("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jackson2Version}") optional("com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${jackson2Version}") optional("com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${jackson2Version}") - optional("org.apache.tiles:tiles-api:${tiles3Version}") - optional("org.apache.tiles:tiles-core:${tiles3Version}") - optional("org.apache.tiles:tiles-servlet:${tiles3Version}") - optional("org.apache.tiles:tiles-jsp:${tiles3Version}") - optional("org.apache.tiles:tiles-el:${tiles3Version}") + optional("org.apache.tiles:tiles-api:${tiles3Version}", withoutJclOverSlf4J) + optional("org.apache.tiles:tiles-core:${tiles3Version}", withoutJclOverSlf4J) + optional("org.apache.tiles:tiles-servlet:${tiles3Version}", withoutJclOverSlf4J) + optional("org.apache.tiles:tiles-jsp:${tiles3Version}", withoutJclOverSlf4J) + optional("org.apache.tiles:tiles-el:${tiles3Version}", withoutJclOverSlf4J) optional("org.apache.tiles:tiles-extras:${tiles3Version}") { exclude group: "org.springframework", module: "spring-web" + exclude group: "org.slf4j", module: "jcl-over-slf4j" } optional("org.codehaus.groovy:groovy-all:${groovyVersion}") optional("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}") diff --git a/spring-websocket/spring-websocket.gradle b/spring-websocket/spring-websocket.gradle index b17d109857..3042abd876 100644 --- a/spring-websocket/spring-websocket.gradle +++ b/spring-websocket/spring-websocket.gradle @@ -1,16 +1,10 @@ description = "Spring WebSocket" -apply plugin: "io.spring.dependency-management" - dependencyManagement { imports { mavenBom "io.projectreactor:reactor-bom:${reactorVersion}" mavenBom "io.netty:netty-bom:${nettyVersion}" } - resolutionStrategy { - cacheChangingModulesFor 0, 'seconds' - } - applyMavenExclusions = false } dependencies {