Skip to content

Commit 1539ba8

Browse files
committed
Refactor Gradle tasks in Spring Framework build
This commit reorganizes tasks and scripts in the build to only apply them where they're needed. We're considering here 3 "types" of projects in our build: * the root project, handling documentation, publishing, etc * framework modules (a project that's published as a spring artifact) * internal modules, such as the BOM, our coroutines support and our integration-tests With this change, we're strealining the project configuration for all spring modules and only applying plugins when needed (typically our kotlin support). See gh-23282
1 parent aa6e762 commit 1539ba8

File tree

15 files changed

+172
-181
lines changed

15 files changed

+172
-181
lines changed

Diff for: build.gradle

+19-81
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,13 @@ plugins {
1414
id 'org.springframework.build.test-sources' apply false
1515
id "io.spring.dependency-management" version "1.0.7.RELEASE" apply false
1616
id "org.jetbrains.kotlin.jvm" version "1.3.41" apply false
17-
id "org.jetbrains.dokka" version "0.9.18"
17+
id "org.jetbrains.dokka" version "0.9.18" apply false
1818
id "org.asciidoctor.convert" version "1.5.8"
1919
}
2020

2121
ext {
22-
linkHomepage = "https://spring.io/projects/spring-framework"
23-
linkCi = "https://build.spring.io/browse/SPR"
24-
linkIssue = "https://github.com/spring-projects/spring-framework/issues"
25-
linkScmUrl = "https://github.com/spring-projects/spring-framework"
26-
linkScmConnection = "scm:git:git://github.com/spring-projects/spring-framework.git"
27-
linkScmDevConnection = "scm:git:ssh://git@github.com:spring-projects/spring-framework.git"
28-
2922
moduleProjects = subprojects.findAll {
30-
(it.name != "spring-framework-bom") && (it.name != "spring-core-coroutines")
23+
(it.name != "spring-framework-bom") && (it.name != "spring-core-coroutines") && (it.name != "integration-tests")
3124
}
3225

3326
aspectjVersion = "1.9.4"
@@ -51,7 +44,6 @@ ext {
5144
tomcatVersion = "9.0.22"
5245
undertowVersion = "2.0.23.Final"
5346

54-
gradleScriptDir = "${rootProject.projectDir}/gradle"
5547
withoutJclOverSlf4j = {
5648
exclude group: "org.slf4j", module: "jcl-over-slf4j"
5749
}
@@ -61,13 +53,10 @@ configure(allprojects) { project ->
6153
group = "org.springframework"
6254

6355
apply plugin: "java"
64-
apply plugin: "kotlin"
6556
apply plugin: "checkstyle"
6657
apply plugin: 'org.springframework.build.compile'
67-
apply plugin: 'org.springframework.build.optional-dependencies'
68-
apply plugin: 'org.springframework.build.test-sources'
6958
apply plugin: "io.spring.dependency-management"
70-
apply from: "${gradleScriptDir}/ide.gradle"
59+
apply from: "${rootDir}/gradle/ide.gradle"
7160

7261
dependencyManagement {
7362
resolutionStrategy {
@@ -96,17 +85,19 @@ configure(allprojects) { project ->
9685
}
9786
}
9887

99-
compileKotlin {
100-
kotlinOptions {
101-
jvmTarget = "1.8"
102-
freeCompilerArgs = ["-Xjsr305=strict"]
88+
pluginManager.withPlugin("kotlin") {
89+
apply plugin: "org.jetbrains.dokka"
90+
compileKotlin {
91+
kotlinOptions {
92+
jvmTarget = "1.8"
93+
freeCompilerArgs = ["-Xjsr305=strict"]
94+
}
10395
}
104-
}
105-
106-
compileTestKotlin {
107-
kotlinOptions {
108-
jvmTarget = "1.8"
109-
freeCompilerArgs = ["-Xjsr305=strict"]
96+
compileTestKotlin {
97+
kotlinOptions {
98+
jvmTarget = "1.8"
99+
freeCompilerArgs = ["-Xjsr305=strict"]
100+
}
110101
}
111102
}
112103

@@ -179,67 +170,18 @@ configure(allprojects) { project ->
179170
] as String[]
180171
}
181172

182-
configure(subprojects.findAll { (it.name != "spring-core-coroutines"
183-
&& it.name != "spring-integration-tests") } ) { subproject ->
184-
apply from: "${gradleScriptDir}/publish-maven.gradle"
185-
186-
jar {
187-
manifest.attributes["Implementation-Title"] = subproject.name
188-
manifest.attributes["Implementation-Version"] = subproject.version
189-
manifest.attributes["Automatic-Module-Name"] = subproject.name.replace('-', '.') // for Jigsaw
190-
manifest.attributes["Created-By"] =
191-
"${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})"
192-
193-
from("${rootProject.projectDir}/src/docs/dist") {
194-
include "license.txt"
195-
include "notice.txt"
196-
into "META-INF"
197-
expand(copyright: new Date().format("yyyy"), version: project.version)
198-
}
199-
}
200-
201-
javadoc {
202-
description = "Generates project-level javadoc for use in -javadoc jar"
203-
204-
options.encoding = "UTF-8"
205-
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
206-
options.author = true
207-
options.header = project.name
208-
options.use = true
209-
options.links(project.ext.javadocLinks)
210-
options.addStringOption("Xdoclint:none", "-quiet")
211-
212-
// Suppress warnings due to cross-module @see and @link references.
213-
// Note that global 'api' task does display all warnings.
214-
logging.captureStandardError LogLevel.INFO
215-
logging.captureStandardOutput LogLevel.INFO // suppress "## warnings" message
216-
}
217-
218-
task sourcesJar(type: Jar, dependsOn: classes) {
219-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
220-
classifier = "sources"
221-
from sourceSets.main.allSource
222-
// Don't include or exclude anything explicitly by default. See SPR-12085.
223-
}
224-
225-
task javadocJar(type: Jar) {
226-
classifier = "javadoc"
227-
from javadoc
228-
}
229-
230-
artifacts {
231-
archives sourcesJar
232-
archives javadocJar
233-
}
173+
configure(moduleProjects) { project ->
174+
apply from: "${rootDir}/gradle/spring-module.gradle"
234175
}
235176

236177
configure(rootProject) {
237178
description = "Spring Framework"
238179

239180
apply plugin: "groovy"
181+
apply plugin: "kotlin"
240182
apply plugin: "io.spring.nohttp"
241183
apply plugin: 'org.springframework.build.api-diff'
242-
apply from: "${gradleScriptDir}/docs.gradle"
184+
apply from: "${rootDir}/gradle/docs.gradle"
243185

244186
nohttp {
245187
source.exclude "**/test-output/**"
@@ -258,9 +200,6 @@ configure(rootProject) {
258200
}
259201
}
260202

261-
// Don't publish the default jar for the root project
262-
configurations.archives.artifacts.clear()
263-
264203
dependencies {
265204
asciidoctor("io.spring.asciidoctor:spring-asciidoctor-extensions:0.1.3.RELEASE")
266205
}
@@ -270,6 +209,5 @@ configure(rootProject) {
270209
archives schemaZip
271210
archives distZip
272211
}
273-
274212
}
275213

0 commit comments

Comments
 (0)