build.gradle 10.2 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.20" apply false
18
	id "org.jetbrains.dokka" version "0.9.15"
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.13"
47
	ext.hsqldbVersion        = "2.4.0"
48
	ext.jackson2Version      = "2.9.3"
49
	ext.jettyVersion         = "9.4.8.v20171121"
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.20"
54
	ext.log4jVersion         = "2.10.0"
J
Juergen Hoeller 已提交
55
	ext.nettyVersion         = "4.1.20.Final"
56
	ext.reactorVersion       = "Bismuth-BUILD-SNAPSHOT"
J
Juergen Hoeller 已提交
57
	ext.rxjavaVersion        = "1.3.4"
58
	ext.rxjavaAdapterVersion = "1.2.1"
59
	ext.rxjava2Version       = "2.1.8"
60
	ext.slf4jVersion         = "1.7.25"
61
	ext.tiles3Version        = "3.0.8"
62
	ext.tomcatVersion        = "8.5.24"
63
	ext.undertowVersion      = "1.4.22.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"
		}
80

S
Sebastien Deleuze 已提交
81 82
	}
	compileTestKotlin {
S
sdeleuze 已提交
83 84
		kotlinOptions {
			jvmTarget = "1.8"
85
			freeCompilerArgs = ["-Xjsr305=strict"]
S
sdeleuze 已提交
86
		}
S
Sebastien Deleuze 已提交
87 88
	}

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

94 95 96 97
	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 已提交
98

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

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

107
	compileJava {
108 109
		sourceCompatibility = 1.8
		targetCompatibility = 1.8
110
		options.encoding = 'UTF-8'
111 112 113
	}

	compileTestJava {
J
Juergen Hoeller 已提交
114 115
		sourceCompatibility = 1.8
		targetCompatibility = 1.8
116
		options.encoding = 'UTF-8'
117
		options.compilerArgs += "-parameters"
J
Juergen Hoeller 已提交
118 119
	}

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

132
	repositories {
B
Brian Clozel 已提交
133
		maven { url "https://repo.spring.io/libs-release" }
134 135
		maven { url "https://repo.spring.io/milestone" }  // for AspectJ 1.9 beta
		maven { url "https://repo.spring.io/snapshot" }   // for Reactor snapshots
136
	}
C
Chris Beams 已提交
137

138
	dependencies {
139
		testCompile("junit:junit:4.12") {
140 141
			exclude group:'org.hamcrest', module:'hamcrest-core'
		}
142
		testCompile("org.mockito:mockito-core:2.12.0") {
143 144
			exclude group:'org.hamcrest', module:'hamcrest-core'
		}
S
Sebastien Deleuze 已提交
145 146 147 148 149
		testCompile("com.nhaarman:mockito-kotlin:1.5.0") {
			exclude module:'kotlin-stdlib'
			exclude module:'kotlin-reflect'
			exclude module:'mockito-core'
		}
150 151
		testCompile("org.hamcrest:hamcrest-all:1.3")
		testCompile("org.xmlunit:xmlunit-matchers:2.3.0")
152
		testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}")
153 154 155
        // 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")
156
	}
C
Chris Beams 已提交
157 158

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

178
configure(subprojects - project(":spring-build-src")) { subproject ->
179 180 181
	apply from: "${gradleScriptDir}/publish-maven.gradle"

	jar {
P
Phillip Webb 已提交
182 183
		manifest.attributes["Implementation-Title"] = subproject.name
		manifest.attributes["Implementation-Version"] = subproject.version
184 185 186
		manifest.attributes["Automatic-Module-Name"] = subproject.name.replace('-', '.')  // for Jigsaw
		manifest.attributes["Created-By"] =
				"${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})"
187 188 189 190 191

		from("${rootProject.projectDir}/src/dist") {
			include "license.txt"
			include "notice.txt"
			into "META-INF"
P
Phillip Webb 已提交
192
			expand(copyright: new Date().format("yyyy"), version: project.version)
193 194 195 196
		}
	}

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

199 200 201
		options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
		options.author = true
		options.header = project.name
202
		options.use = true
C
Chris Beams 已提交
203
		options.links(project.ext.javadocLinks)
204
		options.addStringOption('Xdoclint:none', '-quiet')
C
Chris Beams 已提交
205

206 207
		// Suppress warnings due to cross-module @see and @link references.
		// Note that global 'api' task does display all warnings.
C
Chris Beams 已提交
208
		logging.captureStandardError LogLevel.INFO
209
		logging.captureStandardOutput LogLevel.INFO  // suppress "## warnings" message
210 211
	}

212
	task sourcesJar(type: Jar, dependsOn: classes) {
213
		duplicatesStrategy = DuplicatesStrategy.EXCLUDE
214
		classifier = 'sources'
215
		from sourceSets.main.allSource
216
		// Don't include or exclude anything explicitly by default. See SPR-12085.
217 218 219
	}

	task javadocJar(type: Jar) {
P
Phillip Webb 已提交
220
		classifier = "javadoc"
221 222 223 224 225 226 227
		from javadoc
	}

	artifacts {
		archives sourcesJar
		archives javadocJar
	}
C
Chris Beams 已提交
228 229
}

230
configure(rootProject) {
P
Phillip Webb 已提交
231
	description = "Spring Framework"
232

233
	apply plugin: "groovy"
R
Rob Winch 已提交
234
	apply plugin: "io.spring.dependency-management"
235
	apply from: "${gradleScriptDir}/jdiff.gradle"
236
	apply from: "${gradleScriptDir}/docs.gradle"
237

R
Rob Winch 已提交
238 239 240 241 242 243 244 245 246 247
	dependencyManagement {
		imports {
			mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
		}
		resolutionStrategy {
			cacheChangingModulesFor 0, 'seconds'
		}
		applyMavenExclusions = false
	}

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

251
	dependencies {  // for integration tests
252
		testCompile(project(":spring-aop"))
253
		testCompile(project(":spring-beans"))
254
		testCompile(project(":spring-context"))
255 256
		testCompile(project(":spring-core"))
		testCompile(project(":spring-expression"))
257
		testCompile(project(":spring-jdbc"))
258
		testCompile(project(":spring-orm"))
259
		testCompile(project(":spring-test"))
260
		testCompile(project(":spring-tx"))
261
		testCompile(project(":spring-web"))
262
		testCompile("javax.inject:javax.inject:1")
263 264
		testCompile("javax.resource:javax.resource-api:1.7")
		testCompile("javax.servlet:javax.servlet-api:3.1.0")
265
		testCompile("org.aspectj:aspectjweaver:${aspectjVersion}")
P
Phillip Webb 已提交
266
		testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
267
		testCompile("org.hibernate:hibernate-core:5.1.10.Final")
268 269 270 271 272 273 274 275 276
	}

	artifacts {
		archives docsZip
		archives schemaZip
		archives distZip
	}

	task wrapper(type: Wrapper) {
P
Phillip Webb 已提交
277
		description = "Generates gradlew[.bat] scripts"
278
		gradleVersion = '4.4.1'
279 280

		doLast() {
281
			def gradleOpts = "-XX:MaxMetaspaceSize=1024m -Xmx1024m"
282
			def gradleBatOpts = "$gradleOpts -XX:MaxHeapSize=256m"
P
Phillip Webb 已提交
283
			File wrapperFile = file("gradlew")
284
			wrapperFile.text = wrapperFile.text.replace("DEFAULT_JVM_OPTS=",
285
					"GRADLE_OPTS=\"$gradleOpts \$GRADLE_OPTS\"\nDEFAULT_JVM_OPTS=")
P
Phillip Webb 已提交
286
			File wrapperBatFile = file("gradlew.bat")
287
			wrapperBatFile.text = wrapperBatFile.text.replace("set DEFAULT_JVM_OPTS=",
288
					"set GRADLE_OPTS=$gradleBatOpts %GRADLE_OPTS%\nset DEFAULT_JVM_OPTS=")
289 290
		}
	}
291

292
}
293 294 295 296 297 298 299 300 301 302 303 304

/*
 * 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-")) {
305
			return version.replace('BUILD', qualifier)
306 307
		}
	}
308
	return version
309
}