From 417354da8a57d8a7653f6645a40051edcd810482 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 --- 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 3a7d34382b2..2fb33ab0091 100644 --- a/build.gradle +++ b/build.gradle @@ -27,40 +27,54 @@ ext { moduleProjects = subprojects.findAll { !it.name.equals('spring-build-src') && !it.name.equals('spring-framework-bom') } + + aspectjVersion = "1.9.1" + freemarkerVersion = "2.3.28" + groovyVersion = "2.5.0" + hsqldbVersion = "2.4.1" + jackson2Version = "2.9.5" + jettyVersion = "9.4.11.v20180605" + junitPlatformVersion = "1.2.0" + junitJupiterVersion = "5.2.0" + junitVintageVersion = "5.2.0" + kotlinVersion = "1.2.41" + log4jVersion = "2.11.0" + nettyVersion = "4.1.25.Final" + reactorVersion = "Californium-BUILD-SNAPSHOT" + 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 = "9.0.8" + undertowVersion = "2.0.9.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.9.1" - ext.freemarkerVersion = "2.3.28" - ext.groovyVersion = "2.5.0" - ext.hsqldbVersion = "2.4.1" - ext.jackson2Version = "2.9.5" - ext.jettyVersion = "9.4.11.v20180605" - ext.junitPlatformVersion = "1.2.0" - ext.junitJupiterVersion = "5.2.0" - ext.junitVintageVersion = "5.2.0" - ext.kotlinVersion = "1.2.41" - ext.log4jVersion = "2.11.0" - ext.nettyVersion = "4.1.25.Final" - ext.reactorVersion = "Californium-BUILD-SNAPSHOT" - 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 = "9.0.8" - ext.undertowVersion = "2.0.9.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 { @@ -88,7 +102,6 @@ configure(allprojects) { project -> } } - exclude group: "org.slf4j", module: "jcl-over-slf4j" } def commonCompilerArgs = @@ -231,7 +244,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" @@ -239,10 +251,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 eff54387f69..249d23f4ce9 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 5cc3a33d24f..31d2cf95e86 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 4076574756b..d748629ca43 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 3e2d8060438..b1a31af5ba9 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 62d1be5b36d..3c27337d4d0 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 98b7342ed91..abd18c6f85f 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 5dbc8224b5b..d4347328cc3 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 56f482f5ad0..97e7718400f 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 a31c4cd612d..b6ce38d2777 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 {