build.gradle 10.5 KB
Newer Older
1
buildscript {
2
	repositories {
3
		maven { url "https://repo.spring.io/plugins-release" }
4 5
	}
	dependencies {
6 7
		classpath("io.spring.gradle:propdeps-plugin:0.0.9.RELEASE")
		classpath("org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16")
8
	}
9 10
}

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

S
Stephane Nicoll 已提交
19
ext {
20 21 22 23 24 25
	linkHomepage = "https://projects.spring.io/spring-framework"
	linkCi = "https://build.spring.io/browse/SPR"
	linkIssue = "https://jira.spring.io/browse/SPR"
	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"
26

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

31
	aspectjVersion       = "1.9.2"
32
	freemarkerVersion    = "2.3.28"
33
	groovyVersion        = "2.5.5"
34
	hsqldbVersion        = "2.4.1"
J
Juergen Hoeller 已提交
35
	jackson2Version      = "2.9.8"
36
	jettyVersion         = "9.4.14.v20181114"
S
Sam Brannen 已提交
37
	junit5Version        = "5.3.2"
38
	kotlinVersion        = "1.2.71"
39
	log4jVersion         = "2.11.1"
40
	nettyVersion         = "4.1.32.Final"
41
	reactorVersion       = "Californium-SR4"
42 43
	rxjavaVersion        = "1.3.8"
	rxjavaAdapterVersion = "1.2.1"
44
	rxjava2Version       = "2.2.5"
45 46
	slf4jVersion         = "1.7.25"	  // spring-jcl + consistent 3rd party deps
	tiles3Version        = "3.0.8"
J
Juergen Hoeller 已提交
47
	tomcatVersion        = "9.0.14"
48
	undertowVersion      = "2.0.16.Final"
49 50 51

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

C
Chris Beams 已提交
56
configure(allprojects) { project ->
57
	group = "org.springframework"
58
	version = qualifyVersionIfNecessary(version)
59

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

68 69
	dependencyManagement {
		resolutionStrategy {
70
			cacheChangingModulesFor 0, "seconds"
71 72 73 74 75 76 77
		}
		applyMavenExclusions = false
		generatedPomCustomization {
			enabled = false
		}
	}

78
	configurations.all {
J
Juergen Hoeller 已提交
79
		// Check for updates every build
80
		resolutionStrategy.cacheChangingModulesFor 0, "seconds"
81 82 83

		// Consistent slf4j version (e.g. clashes between slf4j versions)
		resolutionStrategy.eachDependency { DependencyResolveDetails details ->
84
			if (details.requested.group == "org.slf4j") {
85 86 87
				details.useVersion slf4jVersion
			}
		}
88 89
	}

90
	def commonCompilerArgs =
91 92 93
			["-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 已提交
94

95
	compileJava.options*.compilerArgs = commonCompilerArgs +
96 97
			["-Xlint:varargs", "-Xlint:fallthrough", "-Xlint:rawtypes",
			 "-Xlint:deprecation", "-Xlint:unchecked", "-Werror"]
B
Brian Clozel 已提交
98

99
	compileTestJava.options*.compilerArgs = commonCompilerArgs +
100 101
			["-Xlint:-varargs", "-Xlint:-fallthrough", "-Xlint:-rawtypes",
			 "-Xlint:-deprecation", "-Xlint:-unchecked"]
P
Phillip Webb 已提交
102

103
	compileJava {
104
		sourceCompatibility = 1.8  // can be switched to 11 for testing
105
		targetCompatibility = 1.8
106
		options.encoding = "UTF-8"
107 108 109
	}

	compileTestJava {
110
		sourceCompatibility = 1.8  // can be switched to 11 for testing
J
Juergen Hoeller 已提交
111
		targetCompatibility = 1.8
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
		options.encoding = "UTF-8"
		options.compilerArgs += "-parameters"
	}

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

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

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

145
	checkstyle {
J
Juergen Hoeller 已提交
146
		toolVersion = "8.16"
147 148 149
		configDir = rootProject.file("src/checkstyle")
	}

150
	repositories {
151
		maven { url "https://repo.spring.io/libs-release" }
152
	}
C
Chris Beams 已提交
153

154
	dependencies {
155 156
		testCompile("junit:junit:4.12") {
			exclude group: "org.hamcrest", module: "hamcrest-core"
157
		}
158
		testCompile("org.mockito:mockito-core:2.23.4") {
159
			exclude group: "org.hamcrest", module: "hamcrest-core"
160
		}
161 162 163 164
		testCompile("com.nhaarman:mockito-kotlin:1.6.0") {
			exclude module: "kotlin-stdlib"
			exclude module: "kotlin-reflect"
			exclude module: "mockito-core"
S
Sebastien Deleuze 已提交
165
		}
166
		testCompile("org.hamcrest:hamcrest-all:1.3")
167
		testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}")
168 169
		testRuntime("org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}")
		testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}")
P
Phillip Webb 已提交
170
		// JSR-305 only used for non-required meta-annotations
171 172 173
		compileOnly("com.google.code.findbugs:jsr305:3.0.2")
		testCompileOnly("com.google.code.findbugs:jsr305:3.0.2")
		checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.5")
174
	}
C
Chris Beams 已提交
175 176

	ext.javadocLinks = [
177 178 179 180 181 182 183 184 185 186 187 188
		"http://docs.oracle.com/javase/8/docs/api/",
		"http://docs.oracle.com/javaee/7/api/",
		"http://docs.oracle.com/cd/E13222_01/wls/docs90/javadocs/",  // CommonJ
		"http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.javadoc.doc/web/apidocs/",
		"http://glassfish.java.net/nonav/docs/v3/api/",
		"http://docs.jboss.org/jbossas/javadoc/4.0.5/connector/",
		"http://docs.jboss.org/jbossas/javadoc/7.1.2.Final/",
		"http://tiles.apache.org/tiles-request/apidocs/",
		"http://tiles.apache.org/framework/apidocs/",
		"http://www.eclipse.org/aspectj/doc/released/aspectj5rt-api/",
		"http://ehcache.org/apidocs/2.10.4",
		"http://quartz-scheduler.org/api/2.2.1/",
189 190 191
		"http://fasterxml.github.io/jackson-core/javadoc/2.9/",
		"http://fasterxml.github.io/jackson-databind/javadoc/2.9/",
		"http://fasterxml.github.io/jackson-dataformat-xml/javadoc/2.9/",
192
		"http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/",
193
		"https://junit.org/junit4/javadoc/4.12/",
194
		"https://junit.org/junit5/docs/${junit5Version}/api/"
C
Chris Beams 已提交
195
	] as String[]
196 197
}

198
configure(subprojects - project(":spring-build-src")) { subproject ->
199 200 201
	apply from: "${gradleScriptDir}/publish-maven.gradle"

	jar {
202 203 204 205 206
		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")})"
207

208
		from("${rootProject.projectDir}/src/docs/dist") {
209 210 211 212
			include "license.txt"
			include "notice.txt"
			into "META-INF"
			expand(copyright: new Date().format("yyyy"), version: project.version)
213 214 215 216
		}
	}

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

219 220 221
		options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
		options.author = true
		options.header = project.name
222
		options.use = true
C
Chris Beams 已提交
223
		options.links(project.ext.javadocLinks)
224
		options.addStringOption("Xdoclint:none", "-quiet")
C
Chris Beams 已提交
225

226 227
		// Suppress warnings due to cross-module @see and @link references.
		// Note that global 'api' task does display all warnings.
C
Chris Beams 已提交
228
		logging.captureStandardError LogLevel.INFO
229
		logging.captureStandardOutput LogLevel.INFO  // suppress "## warnings" message
230 231
	}

232
	task sourcesJar(type: Jar, dependsOn: classes) {
233
		duplicatesStrategy = DuplicatesStrategy.EXCLUDE
234
		classifier = "sources"
235
		from sourceSets.main.allSource
236
		// Don't include or exclude anything explicitly by default. See SPR-12085.
237 238 239
	}

	task javadocJar(type: Jar) {
240
		classifier = "javadoc"
241 242 243 244 245 246 247
		from javadoc
	}

	artifacts {
		archives sourcesJar
		archives javadocJar
	}
C
Chris Beams 已提交
248 249
}

250
configure(rootProject) {
251
	description = "Spring Framework"
252

253
	apply plugin: "groovy"
254
	apply from: "${gradleScriptDir}/jdiff.gradle"
255
	apply from: "${gradleScriptDir}/docs.gradle"
256

R
Rob Winch 已提交
257 258 259 260 261 262
	dependencyManagement {
		imports {
			mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
		}
	}

263
	// Don't publish the default jar for the root project
264 265
	configurations.archives.artifacts.clear()

266
	dependencies {  // for integration tests
267 268 269 270 271 272 273 274 275 276 277 278 279
		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")
280
		testCompile("org.aspectj:aspectjweaver:${aspectjVersion}")
P
Phillip Webb 已提交
281
		testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
282
		testCompile("org.hibernate:hibernate-core:5.1.16.Final")
283 284 285 286 287 288 289 290
	}

	artifacts {
		archives docsZip
		archives schemaZip
		archives distZip
	}

S
Sam Brannen 已提交
291
	wrapper {
292
		doLast() {
293
			def gradleOpts = "-XX:MaxMetaspaceSize=1024m -Xmx1024m"
294
			def gradleBatOpts = "$gradleOpts -XX:MaxHeapSize=256m"
295 296
			File wrapperFile = file("gradlew")
			wrapperFile.text = wrapperFile.text.replace("DEFAULT_JVM_OPTS=",
297
					"GRADLE_OPTS=\"$gradleOpts \$GRADLE_OPTS\"\nDEFAULT_JVM_OPTS=")
298 299
			File wrapperBatFile = file("gradlew.bat")
			wrapperBatFile.text = wrapperBatFile.text.replace("set DEFAULT_JVM_OPTS=",
300
					"set GRADLE_OPTS=$gradleBatOpts %GRADLE_OPTS%\nset DEFAULT_JVM_OPTS=")
301 302
		}
	}
303
}
304 305 306 307 308 309 310 311 312

/*
 * 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) {
313 314 315 316
	if (rootProject.hasProperty("BRANCH_NAME")) {
		def qualifier = rootProject.getProperty("BRANCH_NAME")
		if (qualifier.startsWith("SPR-")) {
			return version.replace("BUILD", qualifier)
317 318
		}
	}
319
	return version
320
}