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.14")
		classpath("org.asciidoctor:asciidoctorj-epub3:1.5.0-alpha.6")
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.1.4-3" apply false
18
	id "org.jetbrains.dokka" version "0.9.15"
19
	id "org.asciidoctor.convert" version "1.5.3"
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 45 46 47 48 49
	ext.activationVersion    = "1.1.1"
	ext.aspectjVersion       = "1.9.0.BETA-6"
	ext.freemarkerVersion    = "2.3.26-incubating"
	ext.groovyVersion        = "2.4.12"
	ext.hsqldbVersion        = "2.4.0"
	ext.httpclientVersion    = "4.5.3"
B
Brian Clozel 已提交
50
	ext.jackson2Version      = "2.9.1"
51 52 53 54
	ext.javamailVersion      = "1.6.0"
	ext.jaxbVersion          = "2.2.11"
	ext.jaxwsVersion         = "2.2.11"
	ext.jettyVersion         = "9.4.7.RC0"
S
Sam Brannen 已提交
55 56 57
	ext.junitJupiterVersion  = '5.0.0'
	ext.junitPlatformVersion = '1.0.0'
	ext.junitVintageVersion  = "4.12.0"
S
Sebastien Deleuze 已提交
58
	ext.kotlinVersion        = '1.1.4-3'
59
	ext.log4jVersion         = '2.9.0'
60
	ext.nettyVersion         = "4.1.15.Final"
61
	ext.okhttp3Version       = "3.9.0"
S
Stephane Maldini 已提交
62
	ext.reactorVersion       = "Bismuth-M4"
63
	ext.rxjavaVersion        = '1.3.2'
64 65 66 67 68
	ext.rxjavaAdapterVersion = '1.2.1'
	ext.rxjava2Version       = '2.1.3'
	ext.slf4jVersion         = "1.7.25"
	ext.tiles3Version        = "3.0.7"
	ext.tomcatVersion        = "8.5.20"
69
	ext.undertowVersion      = "1.4.20.Final"
70

71
	ext.gradleScriptDir = "${rootProject.projectDir}/gradle"
72

73
	apply plugin: "propdeps"
P
Phillip Webb 已提交
74
	apply plugin: "java"
75
	apply plugin: "test-source-set-dependencies"
76
	apply from: "${gradleScriptDir}/ide.gradle"
C
Chris Beams 已提交
77

S
Sebastien Deleuze 已提交
78 79 80
	apply plugin: "kotlin"
	compileKotlin {
		kotlinOptions.jvmTarget = "1.8"
81
		kotlinOptions.freeCompilerArgs = ["-Xskip-runtime-version-check", "-Xjsr305-annotations=enable"]
82

S
Sebastien Deleuze 已提交
83 84 85
	}
	compileTestKotlin {
		kotlinOptions.jvmTarget = "1.8"
86
		kotlinOptions.freeCompilerArgs = ["-Xskip-runtime-version-check", "-Xjsr305-annotations=enable"]
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 102
	compileJava.options*.compilerArgs = commonCompilerArgs +
			["-Xlint:varargs", "-Xlint:fallthrough", "-Xlint:rawtypes",
			 "-Xlint:deprecation", "-Xlint:unchecked", "-Werror"]
B
Brian Clozel 已提交
103

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

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

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

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

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

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

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

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

	jar {
P
Phillip Webb 已提交
180 181 182 183
		manifest.attributes["Created-By"] =
			"${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})"
		manifest.attributes["Implementation-Title"] = subproject.name
		manifest.attributes["Implementation-Version"] = subproject.version
184 185 186 187 188

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

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

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

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

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

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

	artifacts {
		archives sourcesJar
		archives javadocJar
	}
C
Chris Beams 已提交
225 226
}

B
Brian Clozel 已提交
227 228 229 230 231 232
configure(moduleProjects) {
	dependencies {
		provided("com.google.code.findbugs:jsr305:3.0.2")
	}
}

233
configure(rootProject) {
P
Phillip Webb 已提交
234
	description = "Spring Framework"
235

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

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

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

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

	artifacts {
		archives docsZip
		archives schemaZip
		archives distZip
	}

	task wrapper(type: Wrapper) {
P
Phillip Webb 已提交
280
		description = "Generates gradlew[.bat] scripts"
281
		gradleVersion = '4.1'
282 283

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

295
}
296 297 298 299 300 301 302 303 304 305 306 307

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