build.gradle 10.6 KB
Newer Older
1
buildscript {
2
	repositories {
3
		maven { url "https://repo.spring.io/plugins-release" }
4 5
	}
	dependencies {
R
Rob Winch 已提交
6
		classpath("io.spring.gradle:propdeps-plugin:0.0.8")
7
		classpath("io.spring.gradle:docbook-reference-plugin:0.3.1")
8 9
		classpath("org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16")
		classpath("org.asciidoctor:asciidoctorj-epub3:1.5.0-alpha.7")
10
	}
11 12
}

13
// 3rd party plugin repositories can be configured in settings.gradle
14
plugins {
B
Brian Clozel 已提交
15
	id "com.gradle.build-scan" version "1.8"
16
	id "io.spring.dependency-management" version "1.0.3.RELEASE" apply false
17
	id "org.jetbrains.kotlin.jvm" version "1.2.31" apply false
S
sdeleuze 已提交
18
	id "org.jetbrains.dokka" version "0.9.16"
19
	id "org.asciidoctor.convert" version "1.5.6"
20 21
}

B
Brian Clozel 已提交
22 23 24 25 26
buildScan {
	licenseAgreementUrl = 'https://gradle.com/terms-of-service'
	licenseAgree = 'yes'
}

S
Stephane Nicoll 已提交
27 28 29 30 31 32
ext {
	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'
33
	linkScmDevConnection = 'scm:git:ssh://git@github.com:spring-projects/spring-framework.git'
34

35
	moduleProjects = subprojects.findAll {
36 37
		!it.name.equals('spring-build-src') && !it.name.equals('spring-framework-bom')
	}
S
Stephane Nicoll 已提交
38 39
}

C
Chris Beams 已提交
40
configure(allprojects) { project ->
41 42
	group = "org.springframework"
	version = qualifyVersionIfNecessary(version)
43

44
	ext.aspectjVersion       = "1.8.13"
J
Juergen Hoeller 已提交
45
	ext.freemarkerVersion    = "2.3.27-incubating"
46
	ext.groovyVersion        = "2.4.14"
47
	ext.hsqldbVersion        = "2.4.0"
48
	ext.jackson2Version      = "2.9.5"
49
	ext.jettyVersion         = "9.4.9.v20180320"
S
Sam Brannen 已提交
50 51 52
	ext.junitJupiterVersion  = "5.0.3"
	ext.junitPlatformVersion = "1.0.3"
	ext.junitVintageVersion  = "4.12.3"
53
	ext.kotlinVersion        = "1.2.31"
J
Juergen Hoeller 已提交
54
	ext.log4jVersion         = "2.11.0"
J
Juergen Hoeller 已提交
55
	ext.nettyVersion         = "4.1.22.Final"
R
Rossen Stoyanchev 已提交
56
	ext.reactorVersion       = "Bismuth-BUILD-SNAPSHOT"
57
	ext.rxjavaVersion        = "1.3.7"
58
	ext.rxjavaAdapterVersion = "1.2.1"
59
	ext.rxjava2Version       = "2.1.12"
J
Juergen Hoeller 已提交
60
	ext.slf4jVersion         = "1.7.25"	 // spring-jcl + consistent 3rd party deps
61
	ext.tiles3Version        = "3.0.8"
62
	ext.tomcatVersion        = "8.5.29"
63
	ext.undertowVersion      = "1.4.23.Final"
64

65
	ext.gradleScriptDir = "${rootProject.projectDir}/gradle"
66

67
	apply plugin: "propdeps"
P
Phillip Webb 已提交
68
	apply plugin: "java"
69
	apply plugin: "test-source-set-dependencies"
70
	apply from: "${gradleScriptDir}/ide.gradle"
C
Chris Beams 已提交
71

S
Sebastien Deleuze 已提交
72 73
	apply plugin: "kotlin"
	compileKotlin {
S
sdeleuze 已提交
74 75
		kotlinOptions {
			jvmTarget = "1.8"
76
			freeCompilerArgs = ["-Xjsr305=strict"]
S
sdeleuze 已提交
77 78 79
			apiVersion = "1.1"
			languageVersion = "1.1"
		}
S
Sebastien Deleuze 已提交
80 81
	}
	compileTestKotlin {
S
sdeleuze 已提交
82 83
		kotlinOptions {
			jvmTarget = "1.8"
84
			freeCompilerArgs = ["-Xjsr305=strict"]
S
sdeleuze 已提交
85
		}
S
Sebastien Deleuze 已提交
86 87
	}

88
	configurations.all {
J
Juergen Hoeller 已提交
89
		// Check for updates every build
90
		resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
91 92 93 94 95 96 97 98 99

		// Consistent slf4j version (e.g. clashes between slf4j versions)
		resolutionStrategy.eachDependency { DependencyResolveDetails details ->
			if (details.requested.group == 'org.slf4j') {
				details.useVersion slf4jVersion
			}
		}

		exclude group: "org.slf4j", module: "jcl-over-slf4j"
100 101
	}

102 103 104 105
	def commonCompilerArgs =
			["-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 已提交
106

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

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

115
	compileJava {
116 117
		sourceCompatibility = 1.8
		targetCompatibility = 1.8
118
		options.encoding = 'UTF-8'
119 120 121
	}

	compileTestJava {
J
Juergen Hoeller 已提交
122 123
		sourceCompatibility = 1.8
		targetCompatibility = 1.8
124
		options.encoding = 'UTF-8'
125
		options.compilerArgs += "-parameters"
J
Juergen Hoeller 已提交
126 127
	}

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

140
	repositories {
B
Brian Clozel 已提交
141
		maven { url "https://repo.spring.io/libs-release" }
142
		maven { url "https://repo.spring.io/milestone" }  // for AspectJ 1.9 beta
R
Rossen Stoyanchev 已提交
143
		maven { url "https://repo.spring.io/snapshot" }  // for Reactor
144
	}
C
Chris Beams 已提交
145

146
	dependencies {
147
		testCompile("junit:junit:4.12") {
148 149
			exclude group:'org.hamcrest', module:'hamcrest-core'
		}
150
		testCompile("org.mockito:mockito-core:2.12.0") {
151 152
			exclude group:'org.hamcrest', module:'hamcrest-core'
		}
S
Sebastien Deleuze 已提交
153 154 155 156 157
		testCompile("com.nhaarman:mockito-kotlin:1.5.0") {
			exclude module:'kotlin-stdlib'
			exclude module:'kotlin-reflect'
			exclude module:'mockito-core'
		}
158 159
		testCompile("org.hamcrest:hamcrest-all:1.3")
		testCompile("org.xmlunit:xmlunit-matchers:2.3.0")
160
		testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}")
161 162
		testRuntime("org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}")
		testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}")
163 164 165
        // JSR-305 only used for non-required meta-annotations
		compileOnly("com.google.code.findbugs:jsr305:3.0.2")
		testCompileOnly("com.google.code.findbugs:jsr305:3.0.2")
166
	}
C
Chris Beams 已提交
167 168

	ext.javadocLinks = [
169
		"http://docs.oracle.com/javase/8/docs/api/",
170
		"http://docs.oracle.com/javaee/7/api/",
171
		"http://docs.oracle.com/cd/E13222_01/wls/docs90/javadocs/",  // CommonJ
J
Juergen Hoeller 已提交
172 173
		"http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.javadoc.doc/web/apidocs/",
		"http://glassfish.java.net/nonav/docs/v3/api/",
P
Phillip Webb 已提交
174 175
		"http://docs.jboss.org/jbossas/javadoc/4.0.5/connector/",
		"http://docs.jboss.org/jbossas/javadoc/7.1.2.Final/",
176
		"http://tiles.apache.org/tiles-request/apidocs/",
J
Juergen Hoeller 已提交
177
		"http://tiles.apache.org/framework/apidocs/",
C
Chris Beams 已提交
178
		"http://www.eclipse.org/aspectj/doc/released/aspectj5rt-api/",
179
		"http://ehcache.org/apidocs/2.10.4",
180
		"http://quartz-scheduler.org/api/2.2.1/",
181 182 183
		"http://fasterxml.github.io/jackson-core/javadoc/2.8/",
		"http://fasterxml.github.io/jackson-databind/javadoc/2.8/",
		"http://fasterxml.github.io/jackson-dataformat-xml/javadoc/2.8/",
184
		"http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/"
C
Chris Beams 已提交
185
	] as String[]
186 187
}

188
configure(subprojects - project(":spring-build-src")) { subproject ->
189 190 191
	apply from: "${gradleScriptDir}/publish-maven.gradle"

	jar {
P
Phillip Webb 已提交
192 193
		manifest.attributes["Implementation-Title"] = subproject.name
		manifest.attributes["Implementation-Version"] = subproject.version
194 195 196
		manifest.attributes["Automatic-Module-Name"] = subproject.name.replace('-', '.')  // for Jigsaw
		manifest.attributes["Created-By"] =
				"${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})"
197 198 199 200 201

		from("${rootProject.projectDir}/src/dist") {
			include "license.txt"
			include "notice.txt"
			into "META-INF"
P
Phillip Webb 已提交
202
			expand(copyright: new Date().format("yyyy"), version: project.version)
203 204 205 206
		}
	}

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

209 210 211
		options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
		options.author = true
		options.header = project.name
212
		options.use = true
C
Chris Beams 已提交
213
		options.links(project.ext.javadocLinks)
214
		options.addStringOption('Xdoclint:none', '-quiet')
C
Chris Beams 已提交
215

216 217
		// Suppress warnings due to cross-module @see and @link references.
		// Note that global 'api' task does display all warnings.
C
Chris Beams 已提交
218
		logging.captureStandardError LogLevel.INFO
219
		logging.captureStandardOutput LogLevel.INFO  // suppress "## warnings" message
220 221
	}

222
	task sourcesJar(type: Jar, dependsOn: classes) {
223
		duplicatesStrategy = DuplicatesStrategy.EXCLUDE
224
		classifier = 'sources'
225
		from sourceSets.main.allSource
226
		// Don't include or exclude anything explicitly by default. See SPR-12085.
227 228 229
	}

	task javadocJar(type: Jar) {
P
Phillip Webb 已提交
230
		classifier = "javadoc"
231 232 233 234 235 236 237
		from javadoc
	}

	artifacts {
		archives sourcesJar
		archives javadocJar
	}
C
Chris Beams 已提交
238 239
}

240
configure(rootProject) {
P
Phillip Webb 已提交
241
	description = "Spring Framework"
242

243
	apply plugin: "groovy"
R
Rob Winch 已提交
244
	apply plugin: "io.spring.dependency-management"
245
	apply from: "${gradleScriptDir}/jdiff.gradle"
246
	apply from: "${gradleScriptDir}/docs.gradle"
247

R
Rob Winch 已提交
248 249 250 251 252 253 254 255 256 257
	dependencyManagement {
		imports {
			mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
		}
		resolutionStrategy {
			cacheChangingModulesFor 0, 'seconds'
		}
		applyMavenExclusions = false
	}

C
Chris Beams 已提交
258
	// don't publish the default jar for the root project
259 260
	configurations.archives.artifacts.clear()

261
	dependencies {  // for integration tests
262
		testCompile(project(":spring-aop"))
263
		testCompile(project(":spring-beans"))
264
		testCompile(project(":spring-context"))
265 266
		testCompile(project(":spring-core"))
		testCompile(project(":spring-expression"))
267
		testCompile(project(":spring-jdbc"))
268
		testCompile(project(":spring-orm"))
269
		testCompile(project(":spring-test"))
270
		testCompile(project(":spring-tx"))
271
		testCompile(project(":spring-web"))
272
		testCompile("javax.inject:javax.inject:1")
273 274
		testCompile("javax.resource:javax.resource-api:1.7")
		testCompile("javax.servlet:javax.servlet-api:3.1.0")
275
		testCompile("org.aspectj:aspectjweaver:${aspectjVersion}")
P
Phillip Webb 已提交
276
		testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
277
		testCompile("org.hibernate:hibernate-core:5.1.13.Final")
278 279 280 281 282 283 284 285 286
	}

	artifacts {
		archives docsZip
		archives schemaZip
		archives distZip
	}

	task wrapper(type: Wrapper) {
P
Phillip Webb 已提交
287
		description = "Generates gradlew[.bat] scripts"
288
		gradleVersion = '4.4.1'
289 290

		doLast() {
291
			def gradleOpts = "-XX:MaxMetaspaceSize=1024m -Xmx1024m"
292
			def gradleBatOpts = "$gradleOpts -XX:MaxHeapSize=256m"
P
Phillip Webb 已提交
293
			File wrapperFile = file("gradlew")
294
			wrapperFile.text = wrapperFile.text.replace("DEFAULT_JVM_OPTS=",
295
					"GRADLE_OPTS=\"$gradleOpts \$GRADLE_OPTS\"\nDEFAULT_JVM_OPTS=")
P
Phillip Webb 已提交
296
			File wrapperBatFile = file("gradlew.bat")
297
			wrapperBatFile.text = wrapperBatFile.text.replace("set DEFAULT_JVM_OPTS=",
298
					"set GRADLE_OPTS=$gradleBatOpts %GRADLE_OPTS%\nset DEFAULT_JVM_OPTS=")
299 300
		}
	}
301

302
}
303 304 305 306 307 308 309 310 311 312 313 314

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