build.gradle 10.7 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
S
Sebastien Deleuze 已提交
17
	id "org.jetbrains.kotlin.jvm" version "1.2.41" apply false
S
Sebastien Deleuze 已提交
18
	id "org.jetbrains.dokka" version "0.9.17"
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.9.1"
45
	ext.freemarkerVersion    = "2.3.28"
S
Sam Brannen 已提交
46
	ext.groovyVersion        = "2.5.0"
47
	ext.hsqldbVersion        = "2.4.0"
48
	ext.jackson2Version      = "2.9.5"
49
	ext.jettyVersion         = "9.4.10.v20180503"
S
Sam Brannen 已提交
50 51 52
	ext.junitPlatformVersion = "1.2.0"
	ext.junitJupiterVersion  = "5.2.0"
	ext.junitVintageVersion  = "5.2.0"
S
Sebastien Deleuze 已提交
53
	ext.kotlinVersion        = "1.2.41"
J
Juergen Hoeller 已提交
54
	ext.log4jVersion         = "2.11.0"
J
Juergen Hoeller 已提交
55
	ext.nettyVersion         = "4.1.25.Final"
56
	ext.reactorVersion       = "Californium-BUILD-SNAPSHOT"
57
	ext.rxjavaVersion        = "1.3.8"
58
	ext.rxjavaAdapterVersion = "1.2.1"
59
	ext.rxjava2Version       = "2.1.14"
60
	ext.slf4jVersion         = "1.7.25"	  // spring-jcl + consistent 3rd party deps
61
	ext.tiles3Version        = "3.0.8"
62
	ext.tomcatVersion        = "9.0.8"
63
	ext.undertowVersion      = "2.0.9.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
		sourceCompatibility = 1.8  // can be switched to 10 for testing
117
		targetCompatibility = 1.8
118
		options.encoding = 'UTF-8'
119 120 121
	}

	compileTestJava {
122
		sourceCompatibility = 1.8  // can be switched to 10 for testing
J
Juergen Hoeller 已提交
123
		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/snapshot" }  // for Reactor
143
	}
C
Chris Beams 已提交
144

145
	dependencies {
146
		testCompile("junit:junit:4.12") {
147 148
			exclude group:'org.hamcrest', module:'hamcrest-core'
		}
149
		testCompile("org.mockito:mockito-core:2.18.0") {
150 151
			exclude group:'org.hamcrest', module:'hamcrest-core'
		}
S
Sebastien Deleuze 已提交
152 153 154 155 156
		testCompile("com.nhaarman:mockito-kotlin:1.5.0") {
			exclude module:'kotlin-stdlib'
			exclude module:'kotlin-reflect'
			exclude module:'mockito-core'
		}
157
		testCompile("org.hamcrest:hamcrest-all:1.3")
158
		testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}")
159 160
		testRuntime("org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}")
		testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}")
161 162 163
        // 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")
164
	}
C
Chris Beams 已提交
165 166

	ext.javadocLinks = [
167
		"http://docs.oracle.com/javase/8/docs/api/",
168
		"http://docs.oracle.com/javaee/7/api/",
169
		"http://docs.oracle.com/cd/E13222_01/wls/docs90/javadocs/",  // CommonJ
J
Juergen Hoeller 已提交
170 171
		"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 已提交
172 173
		"http://docs.jboss.org/jbossas/javadoc/4.0.5/connector/",
		"http://docs.jboss.org/jbossas/javadoc/7.1.2.Final/",
174
		"http://tiles.apache.org/tiles-request/apidocs/",
J
Juergen Hoeller 已提交
175
		"http://tiles.apache.org/framework/apidocs/",
C
Chris Beams 已提交
176
		"http://www.eclipse.org/aspectj/doc/released/aspectj5rt-api/",
177
		"http://ehcache.org/apidocs/2.10.4",
178
		"http://quartz-scheduler.org/api/2.2.1/",
179 180 181
		"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/",
182
		"http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/"
C
Chris Beams 已提交
183
	] as String[]
184 185
}

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

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

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

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

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

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

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

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

	artifacts {
		archives sourcesJar
		archives javadocJar
	}
C
Chris Beams 已提交
236 237
}

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

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

R
Rob Winch 已提交
246 247 248 249
	dependencyManagement {
		imports {
			mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
		}
R
Polish  
Rossen Stoyanchev 已提交
250 251 252
		dependencies {
			dependency "io.projectreactor.netty:reactor-netty:0.8.0.BUILD-SNAPSHOT"
		}
R
Rob Winch 已提交
253 254 255 256 257 258
		resolutionStrategy {
			cacheChangingModulesFor 0, 'seconds'
		}
		applyMavenExclusions = false
	}

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

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

	artifacts {
		archives docsZip
		archives schemaZip
		archives distZip
	}

	task wrapper(type: Wrapper) {
P
Phillip Webb 已提交
288
		description = "Generates gradlew[.bat] scripts"
T
Thor Andreas Rognan 已提交
289
		gradleVersion = '4.6'
290 291

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

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

/*
 * 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-")) {
316
			return version.replace('BUILD', qualifier)
317 318
		}
	}
319
	return version
320
}