build.gradle 11.5 KB
Newer Older
1
buildscript {
2
	repositories {
3
		maven { url "https://repo.spring.io/plugins-release" }
4 5
	}
	dependencies {
6
		classpath("io.spring.gradle:propdeps-plugin:0.0.9.RELEASE")
S
Stephane Nicoll 已提交
7
		classpath("io.spring.nohttp:nohttp-gradle:0.0.3.RELEASE")
B
Brian Clozel 已提交
8
		classpath("org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16")
9
	}
10 11
}

12
// 3rd party plugin repositories can be configured in settings.gradle
13
plugins {
14
	id "io.spring.dependency-management" version "1.0.7.RELEASE" apply false
15
	id "org.jetbrains.kotlin.jvm" version "1.3.41" apply false
S
Sebastien Deleuze 已提交
16
	id "org.jetbrains.dokka" version "0.9.18"
B
Brian Clozel 已提交
17
	id "org.asciidoctor.convert" version "1.5.8"
B
Brian Clozel 已提交
18 19
}

S
Stephane Nicoll 已提交
20
ext {
B
Brian Clozel 已提交
21
	linkHomepage = "https://spring.io/projects/spring-framework"
22
	linkCi = "https://build.spring.io/browse/SPR"
23
	linkIssue = "https://github.com/spring-projects/spring-framework/issues"
24 25 26
	linkScmUrl = "https://github.com/spring-projects/spring-framework"
	linkScmConnection = "scm:git:git://github.com/spring-projects/spring-framework.git"
	linkScmDevConnection = "scm:git:ssh://git@github.com:spring-projects/spring-framework.git"
27

28
	moduleProjects = subprojects.findAll {
29
		(it.name != "spring-build-src") && (it.name != "spring-framework-bom") && (it.name != "spring-core-coroutines")
30
	}
31

32
	aspectjVersion       = "1.9.4"
33
	coroutinesVersion    = "1.3.0-M2"
34
	freemarkerVersion    = "2.3.28"
J
Juergen Hoeller 已提交
35
	groovyVersion        = "2.5.7"
36
	hsqldbVersion        = "2.5.0"
J
Juergen Hoeller 已提交
37
	jackson2Version      = "2.9.9"
38
	jettyVersion         = "9.4.19.v20190610"
S
Sam Brannen 已提交
39
	junit5Version        = "5.5.1"
40 41 42
	kotlinVersion        = "1.3.41"
	log4jVersion         = "2.12.0"
	nettyVersion         = "4.1.37.Final"
43
	reactorVersion       = "Dysprosium-M2"
44
	rsocketVersion       = "0.12.2-RC4"
45 46
	rxjavaVersion        = "1.3.8"
	rxjavaAdapterVersion = "1.2.1"
47
	rxjava2Version       = "2.2.10"
48
	slf4jVersion         = "1.7.26"	  // spring-jcl + consistent 3rd party deps
49
	tiles3Version        = "3.0.8"
50
	tomcatVersion        = "9.0.22"
51
	undertowVersion      = "2.0.22.Final"
52 53

	gradleScriptDir = "${rootProject.projectDir}/gradle"
54
	withoutJclOverSlf4j = {
55
		exclude group: "org.slf4j", module: "jcl-over-slf4j"
56
	}
S
Stephane Nicoll 已提交
57 58
}

C
Chris Beams 已提交
59
configure(allprojects) { project ->
60
	group = "org.springframework"
61
	version = qualifyVersionIfNecessary(version)
62

63 64 65 66 67 68
	apply plugin: "java"
	apply plugin: "kotlin"
	apply plugin: "checkstyle"
	apply plugin: "propdeps"
	apply plugin: "test-source-set-dependencies"
	apply plugin: "io.spring.dependency-management"
69
	apply from: "${gradleScriptDir}/ide.gradle"
C
Chris Beams 已提交
70

71 72
	dependencyManagement {
		resolutionStrategy {
73
			cacheChangingModulesFor 0, "seconds"
74 75 76 77 78
		}
		applyMavenExclusions = false
		generatedPomCustomization {
			enabled = false
		}
79 80
		imports {
			mavenBom "org.junit:junit-bom:${junit5Version}"
S
Sebastien Deleuze 已提交
81
			mavenBom "org.jetbrains.kotlin:kotlin-bom:${kotlinVersion}"
82
		}
83 84
	}

85
	configurations.all {
J
Juergen Hoeller 已提交
86
		// Check for updates every build
87
		resolutionStrategy.cacheChangingModulesFor 0, "seconds"
88 89 90

		// Consistent slf4j version (e.g. clashes between slf4j versions)
		resolutionStrategy.eachDependency { DependencyResolveDetails details ->
91
			if (details.requested.group == "org.slf4j") {
92 93 94
				details.useVersion slf4jVersion
			}
		}
95 96
	}

97
	def commonCompilerArgs =
98 99 100
			["-Xlint:serial", "-Xlint:cast", "-Xlint:classfile", "-Xlint:dep-ann",
			 "-Xlint:divzero", "-Xlint:empty", "-Xlint:finally", "-Xlint:overrides",
			 "-Xlint:path", "-Xlint:processing", "-Xlint:static", "-Xlint:try", "-Xlint:-options"]
B
Brian Clozel 已提交
101

102
	compileJava.options*.compilerArgs = commonCompilerArgs +
103 104
			["-Xlint:varargs", "-Xlint:fallthrough", "-Xlint:rawtypes",
			 "-Xlint:deprecation", "-Xlint:unchecked", "-Werror"]
B
Brian Clozel 已提交
105

106
	compileTestJava.options*.compilerArgs = commonCompilerArgs +
107 108
			["-Xlint:-varargs", "-Xlint:-fallthrough", "-Xlint:-rawtypes",
			 "-Xlint:-deprecation", "-Xlint:-unchecked"]
P
Phillip Webb 已提交
109

110
	compileJava {
111
		sourceCompatibility = 1.8  // can be switched to 11 for testing
112
		targetCompatibility = 1.8
113
		options.encoding = "UTF-8"
114 115 116
	}

	compileTestJava {
117
		sourceCompatibility = 1.8  // can be switched to 11 for testing
J
Juergen Hoeller 已提交
118
		targetCompatibility = 1.8
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
		options.encoding = "UTF-8"
		options.compilerArgs += "-parameters"
	}

	compileKotlin {
		kotlinOptions {
			jvmTarget = "1.8"
			freeCompilerArgs = ["-Xjsr305=strict"]
		}
	}

	compileTestKotlin {
		kotlinOptions {
			jvmTarget = "1.8"
			freeCompilerArgs = ["-Xjsr305=strict"]
		}
J
Juergen Hoeller 已提交
135 136
	}

C
Chris Beams 已提交
137
	test {
138 139
		systemProperty("java.awt.headless", "true")
		systemProperty("testGroups", project.properties.get("testGroups"))
140
		systemProperty("io.netty.leakDetection.level", "paranoid")
141
		useJUnitPlatform()
142
		scanForTestClasses = false
143
		include(["**/*Tests.class", "**/*Test.class"])
144 145
		// Since we set scanForTestClasses to false, we need to filter out inner
		// classes with the "$" pattern; otherwise, using -Dtest.single=MyTests to
146
		// run MyTests by itself will fail if MyTests contains any inner classes.
147
		exclude(["**/Abstract*.class", '**/*$*'])
B
Brian Clozel 已提交
148
		reports.junitXml.setDestination(file("$buildDir/test-results"))
C
Chris Beams 已提交
149
	}
C
Chris Beams 已提交
150

151
	checkstyle {
152
		toolVersion = "8.22"
153 154 155
		configDir = rootProject.file("src/checkstyle")
	}

156
	repositories {
157
		mavenCentral()
158
		maven { url "https://repo.spring.io/libs-release" }
159
		maven { url "https://repo.spring.io/milestone" } // Reactor
160
		mavenLocal()
161
	}
C
Chris Beams 已提交
162

163
	dependencies {
S
Sam Brannen 已提交
164
		testCompile("junit:junit:4.13-beta-3") {
165
			exclude group: "org.hamcrest", module: "hamcrest-core"
166
		}
S
Sam Brannen 已提交
167
		testCompile("org.mockito:mockito-core:3.0.0") {
168
			exclude group: "org.hamcrest", module: "hamcrest-core"
169
		}
170
		testCompile("io.mockk:mockk:1.9.3")
171
		testCompile("org.hamcrest:hamcrest-all:1.3")
172
		testCompile("org.assertj:assertj-core:3.12.2")
173 174 175 176
		// Pull in the latest JUnit 5 Launcher API and the Vintage engine as well
		// so that we can run JUnit 4 tests in IDEs.
		testRuntime("org.junit.platform:junit-platform-launcher")
		testRuntime("org.junit.vintage:junit-vintage-engine")
177
		testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}")
178 179
		testRuntime("org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}")
		testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}")
P
Phillip Webb 已提交
180
		// JSR-305 only used for non-required meta-annotations
181 182
		compileOnly("com.google.code.findbugs:jsr305:3.0.2")
		testCompileOnly("com.google.code.findbugs:jsr305:3.0.2")
183
		checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.7")
184
	}
C
Chris Beams 已提交
185 186

	ext.javadocLinks = [
S
Spring Operator 已提交
187 188
		"https://docs.oracle.com/javase/8/docs/api/",
		"https://docs.oracle.com/javaee/7/api/",
S
Sam Brannen 已提交
189 190
		"https://docs.oracle.com/cd/E13222_01/wls/docs90/javadocs/",  // CommonJ
		"https://www.ibm.com/support/knowledgecenter/SS7JFU_8.5.5/com.ibm.websphere.javadoc.doc/web/apidocs/",
S
Spring Operator 已提交
191 192 193 194 195 196 197
		"https://glassfish.java.net/nonav/docs/v3/api/",
		"https://docs.jboss.org/jbossas/javadoc/4.0.5/connector/",
		"https://docs.jboss.org/jbossas/javadoc/7.1.2.Final/",
		"https://tiles.apache.org/tiles-request/apidocs/",
		"https://tiles.apache.org/framework/apidocs/",
		"https://www.eclipse.org/aspectj/doc/released/aspectj5rt-api/",
		"https://www.ehcache.org/apidocs/2.10.4",
198
		"https://www.quartz-scheduler.org/api/2.3.0/",
S
Spring Operator 已提交
199 200 201 202
		"https://fasterxml.github.io/jackson-core/javadoc/2.9/",
		"https://fasterxml.github.io/jackson-databind/javadoc/2.9/",
		"https://fasterxml.github.io/jackson-dataformat-xml/javadoc/2.9/",
		"https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/",
203
		"https://junit.org/junit4/javadoc/4.12/",
204
		"https://junit.org/junit5/docs/${junit5Version}/api/"
C
Chris Beams 已提交
205
	] as String[]
206 207
}

208
configure(subprojects.findAll { (it.name != "spring-build-src") && (it.name != "spring-core-coroutines") } ) { subproject ->
209 210 211
	apply from: "${gradleScriptDir}/publish-maven.gradle"

	jar {
212 213 214 215 216
		manifest.attributes["Implementation-Title"] = subproject.name
		manifest.attributes["Implementation-Version"] = subproject.version
		manifest.attributes["Automatic-Module-Name"] = subproject.name.replace('-', '.')  // for Jigsaw
		manifest.attributes["Created-By"] =
				"${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})"
217

218
		from("${rootProject.projectDir}/src/docs/dist") {
219 220 221 222
			include "license.txt"
			include "notice.txt"
			into "META-INF"
			expand(copyright: new Date().format("yyyy"), version: project.version)
223 224 225 226
		}
	}

	javadoc {
227
		description = "Generates project-level javadoc for use in -javadoc jar"
C
Chris Beams 已提交
228

229
		options.encoding = "UTF-8"
230 231 232
		options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
		options.author = true
		options.header = project.name
233
		options.use = true
C
Chris Beams 已提交
234
		options.links(project.ext.javadocLinks)
235
		options.addStringOption("Xdoclint:none", "-quiet")
C
Chris Beams 已提交
236

237 238
		// Suppress warnings due to cross-module @see and @link references.
		// Note that global 'api' task does display all warnings.
C
Chris Beams 已提交
239
		logging.captureStandardError LogLevel.INFO
240
		logging.captureStandardOutput LogLevel.INFO  // suppress "## warnings" message
241 242
	}

243
	task sourcesJar(type: Jar, dependsOn: classes) {
244
		duplicatesStrategy = DuplicatesStrategy.EXCLUDE
245
		classifier = "sources"
246
		from sourceSets.main.allSource
247
		// Don't include or exclude anything explicitly by default. See SPR-12085.
248 249 250
	}

	task javadocJar(type: Jar) {
251
		classifier = "javadoc"
252 253 254 255 256 257 258
		from javadoc
	}

	artifacts {
		archives sourcesJar
		archives javadocJar
	}
C
Chris Beams 已提交
259 260
}

261
configure(rootProject) {
262
	description = "Spring Framework"
263

264
	apply plugin: "groovy"
R
Rob Winch 已提交
265
	apply plugin: "io.spring.nohttp"
266
	apply from: "${gradleScriptDir}/jdiff.gradle"
267
	apply from: "${gradleScriptDir}/docs.gradle"
268

R
Rob Winch 已提交
269 270 271 272 273 274 275 276 277 278 279
	nohttp {
		source.exclude "**/test-output/**"
		whitelistFile = project.file("src/nohttp/whitelist.lines")
		def projectDirURI = project.projectDir.toURI()
		allprojects.forEach { p ->
			def outURI = p.file("out").toURI()
			def pattern = projectDirURI.relativize(outURI).path + "**"
			source.exclude pattern
		}
	}

R
Rob Winch 已提交
280 281 282 283 284 285
	dependencyManagement {
		imports {
			mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
		}
	}

286
	// Don't publish the default jar for the root project
287 288
	configurations.archives.artifacts.clear()

289
	dependencies {  // for integration tests
290 291 292 293 294 295 296 297 298 299 300 301 302
		testCompile(project(":spring-aop"))
		testCompile(project(":spring-beans"))
		testCompile(project(":spring-context"))
		testCompile(project(":spring-core"))
		testCompile(project(":spring-expression"))
		testCompile(project(":spring-jdbc"))
		testCompile(project(":spring-orm"))
		testCompile(project(":spring-test"))
		testCompile(project(":spring-tx"))
		testCompile(project(":spring-web"))
		testCompile("javax.inject:javax.inject:1")
		testCompile("javax.resource:javax.resource-api:1.7.1")
		testCompile("javax.servlet:javax.servlet-api:3.1.0")
303
		testCompile("org.aspectj:aspectjweaver:${aspectjVersion}")
P
Phillip Webb 已提交
304
		testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
305
		testCompile("org.hibernate:hibernate-core:5.1.17.Final")
306 307 308 309 310 311 312 313
	}

	artifacts {
		archives docsZip
		archives schemaZip
		archives distZip
	}

S
Sam Brannen 已提交
314
	wrapper {
315
		doLast() {
316
			def gradleOpts = "-XX:MaxMetaspaceSize=1024m -Xmx1024m"
317
			def gradleBatOpts = "$gradleOpts -XX:MaxHeapSize=256m"
318 319
			File wrapperFile = file("gradlew")
			wrapperFile.text = wrapperFile.text.replace("DEFAULT_JVM_OPTS=",
320
					"GRADLE_OPTS=\"$gradleOpts \$GRADLE_OPTS\"\nDEFAULT_JVM_OPTS=")
321 322
			File wrapperBatFile = file("gradlew.bat")
			wrapperBatFile.text = wrapperBatFile.text.replace("set DEFAULT_JVM_OPTS=",
323
					"set GRADLE_OPTS=$gradleBatOpts %GRADLE_OPTS%\nset DEFAULT_JVM_OPTS=")
324 325
		}
	}
326
}
327 328 329 330 331 332 333 334 335

/*
 * Support publication of artifacts versioned by topic branch.
 * CI builds supply `-P BRANCH_NAME=<TOPIC>` to gradle at build time.
 * If <TOPIC> starts with 'SPR-', change version
 *     from BUILD-SNAPSHOT => <TOPIC>-SNAPSHOT
 *     e.g. 3.2.1.BUILD-SNAPSHOT => 3.2.1.SPR-1234-SNAPSHOT
 */
def qualifyVersionIfNecessary(version) {
336 337 338 339
	if (rootProject.hasProperty("BRANCH_NAME")) {
		def qualifier = rootProject.getProperty("BRANCH_NAME")
		if (qualifier.startsWith("SPR-")) {
			return version.replace("BUILD", qualifier)
340 341
		}
	}
342
	return version
343
}