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

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

S
Stephane Nicoll 已提交
21
ext {
B
Brian Clozel 已提交
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 26 27
	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"
28

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

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

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

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

64 65 66
	apply plugin: "java"
	apply plugin: "kotlin"
	apply plugin: "checkstyle"
67
	apply plugin: 'org.springframework.build.optional-dependencies'
68
	apply plugin: 'org.springframework.build.test-sources'
69
	apply plugin: "io.spring.dependency-management"
70
	apply from: "${gradleScriptDir}/ide.gradle"
C
Chris Beams 已提交
71

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

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

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

99
	def commonCompilerArgs =
100 101 102
			["-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 已提交
103

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

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

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

	compileTestJava {
119
		sourceCompatibility = 1.8  // can be switched to 11 for testing
J
Juergen Hoeller 已提交
120
		targetCompatibility = 1.8
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
		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 已提交
137 138
	}

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

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

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

164
	dependencies {
S
Sam Brannen 已提交
165
		testCompile("junit:junit:4.13-beta-3") {
166
			exclude group: "org.hamcrest", module: "hamcrest-core"
167
		}
S
Sam Brannen 已提交
168
		testCompile("org.mockito:mockito-core:3.0.0") {
169
			exclude group: "org.hamcrest", module: "hamcrest-core"
170
		}
171
		testCompile("io.mockk:mockk:1.9.3")
172
		testCompile("org.hamcrest:hamcrest-all:1.3")
S
Sam Brannen 已提交
173
		testCompile("org.assertj:assertj-core:3.13.1")
174 175 176 177
		// 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")
178
		testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}")
179 180
		testRuntime("org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}")
		testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}")
P
Phillip Webb 已提交
181
		// JSR-305 only used for non-required meta-annotations
182 183
		compileOnly("com.google.code.findbugs:jsr305:3.0.2")
		testCompileOnly("com.google.code.findbugs:jsr305:3.0.2")
184
		checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.7")
185
	}
C
Chris Beams 已提交
186 187

	ext.javadocLinks = [
S
Spring Operator 已提交
188 189
		"https://docs.oracle.com/javase/8/docs/api/",
		"https://docs.oracle.com/javaee/7/api/",
S
Sam Brannen 已提交
190 191
		"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 已提交
192 193 194 195 196 197 198
		"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",
199
		"https://www.quartz-scheduler.org/api/2.3.0/",
S
Spring Operator 已提交
200 201 202 203
		"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/",
204
		"https://junit.org/junit4/javadoc/4.12/",
205
		"https://junit.org/junit5/docs/${junit5Version}/api/"
C
Chris Beams 已提交
206
	] as String[]
207 208
}

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

	jar {
213 214 215 216 217
		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")})"
218

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

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

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

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

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

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

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

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

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

R
Rob Winch 已提交
270 271 272 273 274 275 276 277 278 279 280
	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 已提交
281 282 283 284 285 286
	dependencyManagement {
		imports {
			mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
		}
	}

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

290
	dependencies {  // for integration tests
291 292 293 294 295 296 297 298 299 300 301 302 303
		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")
304
		testCompile("org.aspectj:aspectjweaver:${aspectjVersion}")
P
Phillip Webb 已提交
305
		testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
306
		testCompile("org.hibernate:hibernate-core:5.1.17.Final")
307
		asciidoctor("io.spring.asciidoctor:spring-asciidoctor-extensions:0.1.3.RELEASE")
308 309 310 311 312 313 314 315
	}

	artifacts {
		archives docsZip
		archives schemaZip
		archives distZip
	}

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

/*
 * 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) {
338 339 340 341
	if (rootProject.hasProperty("BRANCH_NAME")) {
		def qualifier = rootProject.getProperty("BRANCH_NAME")
		if (qualifier.startsWith("SPR-")) {
			return version.replace("BUILD", qualifier)
342 343
		}
	}
344
	return version
345
}