Skip to content

Commit 417354d

Browse files
committed
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
1 parent 7bce750 commit 417354d

File tree

10 files changed

+50
-85
lines changed

10 files changed

+50
-85
lines changed

build.gradle

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,40 +27,54 @@ ext {
2727
moduleProjects = subprojects.findAll {
2828
!it.name.equals('spring-build-src') && !it.name.equals('spring-framework-bom')
2929
}
30+
31+
aspectjVersion = "1.9.1"
32+
freemarkerVersion = "2.3.28"
33+
groovyVersion = "2.5.0"
34+
hsqldbVersion = "2.4.1"
35+
jackson2Version = "2.9.5"
36+
jettyVersion = "9.4.11.v20180605"
37+
junitPlatformVersion = "1.2.0"
38+
junitJupiterVersion = "5.2.0"
39+
junitVintageVersion = "5.2.0"
40+
kotlinVersion = "1.2.41"
41+
log4jVersion = "2.11.0"
42+
nettyVersion = "4.1.25.Final"
43+
reactorVersion = "Californium-BUILD-SNAPSHOT"
44+
rxjavaVersion = "1.3.8"
45+
rxjavaAdapterVersion = "1.2.1"
46+
rxjava2Version = "2.1.14"
47+
slf4jVersion = "1.7.25" // spring-jcl + consistent 3rd party deps
48+
tiles3Version = "3.0.8"
49+
tomcatVersion = "9.0.8"
50+
undertowVersion = "2.0.9.Final"
51+
52+
gradleScriptDir = "${rootProject.projectDir}/gradle"
53+
withoutJclOverSlf4J = {
54+
exclude group: "org.slf4j", module: "jcl-over-slf4j"
55+
}
3056
}
3157

3258
configure(allprojects) { project ->
3359
group = "org.springframework"
3460
version = qualifyVersionIfNecessary(version)
3561

36-
ext.aspectjVersion = "1.9.1"
37-
ext.freemarkerVersion = "2.3.28"
38-
ext.groovyVersion = "2.5.0"
39-
ext.hsqldbVersion = "2.4.1"
40-
ext.jackson2Version = "2.9.5"
41-
ext.jettyVersion = "9.4.11.v20180605"
42-
ext.junitPlatformVersion = "1.2.0"
43-
ext.junitJupiterVersion = "5.2.0"
44-
ext.junitVintageVersion = "5.2.0"
45-
ext.kotlinVersion = "1.2.41"
46-
ext.log4jVersion = "2.11.0"
47-
ext.nettyVersion = "4.1.25.Final"
48-
ext.reactorVersion = "Californium-BUILD-SNAPSHOT"
49-
ext.rxjavaVersion = "1.3.8"
50-
ext.rxjavaAdapterVersion = "1.2.1"
51-
ext.rxjava2Version = "2.1.14"
52-
ext.slf4jVersion = "1.7.25" // spring-jcl + consistent 3rd party deps
53-
ext.tiles3Version = "3.0.8"
54-
ext.tomcatVersion = "9.0.8"
55-
ext.undertowVersion = "2.0.9.Final"
56-
57-
ext.gradleScriptDir = "${rootProject.projectDir}/gradle"
58-
5962
apply plugin: "propdeps"
6063
apply plugin: "java"
6164
apply plugin: "test-source-set-dependencies"
65+
apply plugin: "io.spring.dependency-management"
6266
apply from: "${gradleScriptDir}/ide.gradle"
6367

68+
dependencyManagement {
69+
resolutionStrategy {
70+
cacheChangingModulesFor 0, 'seconds'
71+
}
72+
applyMavenExclusions = false
73+
generatedPomCustomization {
74+
enabled = false
75+
}
76+
}
77+
6478
apply plugin: "kotlin"
6579
compileKotlin {
6680
kotlinOptions {
@@ -88,7 +102,6 @@ configure(allprojects) { project ->
88102
}
89103
}
90104

91-
exclude group: "org.slf4j", module: "jcl-over-slf4j"
92105
}
93106

94107
def commonCompilerArgs =
@@ -231,18 +244,13 @@ configure(rootProject) {
231244
description = "Spring Framework"
232245

233246
apply plugin: "groovy"
234-
apply plugin: "io.spring.dependency-management"
235247
apply from: "${gradleScriptDir}/jdiff.gradle"
236248
apply from: "${gradleScriptDir}/docs.gradle"
237249

238250
dependencyManagement {
239251
imports {
240252
mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
241253
}
242-
resolutionStrategy {
243-
cacheChangingModulesFor 0, 'seconds'
244-
}
245-
applyMavenExclusions = false
246254
}
247255

248256
// don't publish the default jar for the root project

gradle/publish-maven.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ def customizePom(pom, gradleProject) {
1818
"$dep.scope:$dep.groupId:$dep.artifactId"
1919
}
2020

21+
def managedVersions = dependencyManagement.managedVersions
22+
generatedPom.dependencies.findAll{dep -> !dep.version }.each { dep ->
23+
dep.version = managedVersions["${dep.groupId}:${dep.artifactId}"]
24+
}
25+
2126
// add all items necessary for maven central publication
2227
generatedPom.project {
2328
name = gradleProject.description

spring-core/spring-core.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
description = "Spring Core"
22

3-
apply plugin: "io.spring.dependency-management"
4-
53
dependencyManagement {
64
imports {
75
mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
86
mavenBom "io.netty:netty-bom:${nettyVersion}"
97
}
10-
resolutionStrategy {
11-
cacheChangingModulesFor 0, 'seconds'
12-
}
13-
applyMavenExclusions = false
148
}
159

1610
// As of Spring 4.0.3, spring-core includes asm 5.x and repackages cglib 3.2, inlining

spring-framework-bom/spring-framework-bom.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
description = "Spring Framework (Bill of Materials)"
22

3-
dependencyManagement {
4-
generatedPomCustomization {
5-
enabled = false
6-
}
7-
}
8-
93
configurations.archives.artifacts.clear()
104
artifacts {
115
// work around GRADLE-2406 by attaching text artifact

spring-messaging/spring-messaging.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
description = "Spring Messaging"
22

3-
apply plugin: "io.spring.dependency-management"
4-
53
dependencyManagement {
64
imports {
75
mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
86
mavenBom "io.netty:netty-bom:${nettyVersion}"
97
}
10-
resolutionStrategy {
11-
cacheChangingModulesFor 0, 'seconds'
12-
}
13-
applyMavenExclusions = false
148
}
159

1610
dependencies {

spring-test/spring-test.gradle

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
description = "Spring TestContext Framework"
22

3-
apply plugin: "io.spring.dependency-management"
4-
53
dependencyManagement {
64
imports {
75
mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
86
mavenBom "io.netty:netty-bom:${nettyVersion}"
97
}
10-
resolutionStrategy {
11-
cacheChangingModulesFor 0, 'seconds'
12-
}
13-
applyMavenExclusions = false
148
}
159

1610
dependencies {
@@ -74,8 +68,8 @@ dependencies {
7468
testCompile("com.thoughtworks.xstream:xstream:1.4.10")
7569
testCompile("com.rometools:rome:1.9.0")
7670
testCompile("org.apache.tiles:tiles-api:${tiles3Version}")
77-
testCompile("org.apache.tiles:tiles-core:${tiles3Version}")
78-
testCompile("org.apache.tiles:tiles-servlet:${tiles3Version}")
71+
testCompile("org.apache.tiles:tiles-core:${tiles3Version}", withoutJclOverSlf4J)
72+
testCompile("org.apache.tiles:tiles-servlet:${tiles3Version}", withoutJclOverSlf4J)
7973
testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
8074
testCompile("org.apache.httpcomponents:httpclient:4.5.5") {
8175
exclude group: "commons-logging", module: "commons-logging"

spring-web/spring-web.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
description = "Spring Web"
22

3-
apply plugin: "groovy"
4-
apply plugin: "io.spring.dependency-management"
5-
63
dependencyManagement {
74
imports {
85
mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
96
mavenBom "io.netty:netty-bom:${nettyVersion}"
107
}
11-
resolutionStrategy {
12-
cacheChangingModulesFor 0, 'seconds'
13-
}
14-
applyMavenExclusions = false
158
}
169

1710
dependencies {

spring-webflux/spring-webflux.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
description = "Spring WebFlux"
22

3-
apply plugin: "io.spring.dependency-management"
4-
53
dependencyManagement {
64
imports {
75
mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
86
mavenBom "io.netty:netty-bom:${nettyVersion}"
97
}
10-
resolutionStrategy {
11-
cacheChangingModulesFor 0, 'seconds'
12-
}
13-
applyMavenExclusions = false
148
}
159

1610
dependencies {

spring-webmvc/spring-webmvc.gradle

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
description = "Spring Web MVC"
22

3-
apply plugin: "io.spring.dependency-management"
4-
53
dependencyManagement {
64
imports {
75
mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
86
}
9-
resolutionStrategy {
10-
cacheChangingModulesFor 0, 'seconds'
11-
}
12-
applyMavenExclusions = false
137
}
148

159
dependencies {
@@ -35,13 +29,14 @@ dependencies {
3529
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jackson2Version}")
3630
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${jackson2Version}")
3731
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${jackson2Version}")
38-
optional("org.apache.tiles:tiles-api:${tiles3Version}")
39-
optional("org.apache.tiles:tiles-core:${tiles3Version}")
40-
optional("org.apache.tiles:tiles-servlet:${tiles3Version}")
41-
optional("org.apache.tiles:tiles-jsp:${tiles3Version}")
42-
optional("org.apache.tiles:tiles-el:${tiles3Version}")
32+
optional("org.apache.tiles:tiles-api:${tiles3Version}", withoutJclOverSlf4J)
33+
optional("org.apache.tiles:tiles-core:${tiles3Version}", withoutJclOverSlf4J)
34+
optional("org.apache.tiles:tiles-servlet:${tiles3Version}", withoutJclOverSlf4J)
35+
optional("org.apache.tiles:tiles-jsp:${tiles3Version}", withoutJclOverSlf4J)
36+
optional("org.apache.tiles:tiles-el:${tiles3Version}", withoutJclOverSlf4J)
4337
optional("org.apache.tiles:tiles-extras:${tiles3Version}") {
4438
exclude group: "org.springframework", module: "spring-web"
39+
exclude group: "org.slf4j", module: "jcl-over-slf4j"
4540
}
4641
optional("org.codehaus.groovy:groovy-all:${groovyVersion}")
4742
optional("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")

spring-websocket/spring-websocket.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
description = "Spring WebSocket"
22

3-
apply plugin: "io.spring.dependency-management"
4-
53
dependencyManagement {
64
imports {
75
mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
86
mavenBom "io.netty:netty-bom:${nettyVersion}"
97
}
10-
resolutionStrategy {
11-
cacheChangingModulesFor 0, 'seconds'
12-
}
13-
applyMavenExclusions = false
148
}
159

1610
dependencies {

0 commit comments

Comments
 (0)