Skip to content

Commit afcc430

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 (Cherry-picked from 417354d)
1 parent 062a15f commit afcc430

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
@@ -35,40 +35,54 @@ ext {
3535
moduleProjects = subprojects.findAll {
3636
!it.name.equals('spring-build-src') && !it.name.equals('spring-framework-bom')
3737
}
38+
39+
aspectjVersion = "1.8.13"
40+
freemarkerVersion = "2.3.27-incubating"
41+
groovyVersion = "2.4.15"
42+
hsqldbVersion = "2.4.1"
43+
jackson2Version = "2.9.5"
44+
jettyVersion = "9.4.11.v20180605"
45+
junitJupiterVersion = "5.0.3"
46+
junitPlatformVersion = "1.0.3"
47+
junitVintageVersion = "4.12.3"
48+
kotlinVersion = "1.2.41"
49+
log4jVersion = "2.11.0"
50+
nettyVersion = "4.1.25.Final"
51+
reactorVersion = "Bismuth-SR9"
52+
rxjavaVersion = "1.3.8"
53+
rxjavaAdapterVersion = "1.2.1"
54+
rxjava2Version = "2.1.14"
55+
slf4jVersion = "1.7.25" // spring-jcl + consistent 3rd party deps
56+
tiles3Version = "3.0.8"
57+
tomcatVersion = "8.5.31"
58+
undertowVersion = "1.4.25.Final"
59+
60+
gradleScriptDir = "${rootProject.projectDir}/gradle"
61+
withoutJclOverSlf4J = {
62+
exclude group: "org.slf4j", module: "jcl-over-slf4j"
63+
}
3864
}
3965

4066
configure(allprojects) { project ->
4167
group = "org.springframework"
4268
version = qualifyVersionIfNecessary(version)
4369

44-
ext.aspectjVersion = "1.8.13"
45-
ext.freemarkerVersion = "2.3.27-incubating"
46-
ext.groovyVersion = "2.4.15"
47-
ext.hsqldbVersion = "2.4.1"
48-
ext.jackson2Version = "2.9.5"
49-
ext.jettyVersion = "9.4.11.v20180605"
50-
ext.junitJupiterVersion = "5.0.3"
51-
ext.junitPlatformVersion = "1.0.3"
52-
ext.junitVintageVersion = "4.12.3"
53-
ext.kotlinVersion = "1.2.41"
54-
ext.log4jVersion = "2.11.0"
55-
ext.nettyVersion = "4.1.25.Final"
56-
ext.reactorVersion = "Bismuth-SR9"
57-
ext.rxjavaVersion = "1.3.8"
58-
ext.rxjavaAdapterVersion = "1.2.1"
59-
ext.rxjava2Version = "2.1.14"
60-
ext.slf4jVersion = "1.7.25" // spring-jcl + consistent 3rd party deps
61-
ext.tiles3Version = "3.0.8"
62-
ext.tomcatVersion = "8.5.31"
63-
ext.undertowVersion = "1.4.25.Final"
64-
65-
ext.gradleScriptDir = "${rootProject.projectDir}/gradle"
66-
6770
apply plugin: "propdeps"
6871
apply plugin: "java"
6972
apply plugin: "test-source-set-dependencies"
73+
apply plugin: "io.spring.dependency-management"
7074
apply from: "${gradleScriptDir}/ide.gradle"
7175

76+
dependencyManagement {
77+
resolutionStrategy {
78+
cacheChangingModulesFor 0, 'seconds'
79+
}
80+
applyMavenExclusions = false
81+
generatedPomCustomization {
82+
enabled = false
83+
}
84+
}
85+
7286
apply plugin: "kotlin"
7387
compileKotlin {
7488
kotlinOptions {
@@ -96,7 +110,6 @@ configure(allprojects) { project ->
96110
}
97111
}
98112

99-
exclude group: "org.slf4j", module: "jcl-over-slf4j"
100113
}
101114

102115
def commonCompilerArgs =
@@ -238,18 +251,13 @@ configure(rootProject) {
238251
description = "Spring Framework"
239252

240253
apply plugin: "groovy"
241-
apply plugin: "io.spring.dependency-management"
242254
apply from: "${gradleScriptDir}/jdiff.gradle"
243255
apply from: "${gradleScriptDir}/docs.gradle"
244256

245257
dependencyManagement {
246258
imports {
247259
mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
248260
}
249-
resolutionStrategy {
250-
cacheChangingModulesFor 0, 'seconds'
251-
}
252-
applyMavenExclusions = false
253261
}
254262

255263
// 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)