build.gradle 10.1 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.1.51" 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.11"
45 46 47
	ext.freemarkerVersion    = "2.3.26-incubating"
	ext.groovyVersion        = "2.4.12"
	ext.hsqldbVersion        = "2.4.0"
B
Brian Clozel 已提交
48
	ext.jackson2Version      = "2.9.1"
49
	ext.jettyVersion         = "9.4.7.v20170914"
S
Sam Brannen 已提交
50 51 52
	ext.junitJupiterVersion  = '5.0.0'
	ext.junitPlatformVersion = '1.0.0'
	ext.junitVintageVersion  = "4.12.0"
S
Sebastien Deleuze 已提交
53
	ext.kotlinVersion        = '1.1.51'
54
	ext.log4jVersion         = '2.9.1'
55
	ext.nettyVersion         = "4.1.15.Final"
56
	ext.reactorVersion       = "Bismuth-RELEASE"
57
	ext.rxjavaVersion        = '1.3.2'
58
	ext.rxjavaAdapterVersion = '1.2.1'
59
	ext.rxjava2Version       = '2.1.4'
60 61
	ext.slf4jVersion         = "1.7.25"
	ext.tiles3Version        = "3.0.7"
62
	ext.tomcatVersion        = "8.5.21"
63
	ext.undertowVersion      = "1.4.20.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 74
	apply plugin: "kotlin"
	compileKotlin {
		kotlinOptions.jvmTarget = "1.8"
S
Sebastien Deleuze 已提交
75
		kotlinOptions.freeCompilerArgs = ["-Xskip-runtime-version-check", "-Xjsr305=strict"]
76

S
Sebastien Deleuze 已提交
77 78 79
	}
	compileTestKotlin {
		kotlinOptions.jvmTarget = "1.8"
S
Sebastien Deleuze 已提交
80
		kotlinOptions.freeCompilerArgs = ["-Xskip-runtime-version-check", "-Xjsr305=strict"]
S
Sebastien Deleuze 已提交
81 82
	}

83
	configurations.all {
J
Juergen Hoeller 已提交
84
		// Check for updates every build
85 86 87
		resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
	}

88 89 90 91
	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 已提交
92

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

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

101
	compileJava {
102 103
		sourceCompatibility = 1.8
		targetCompatibility = 1.8
104
		options.encoding = 'UTF-8'
105 106 107
	}

	compileTestJava {
J
Juergen Hoeller 已提交
108 109
		sourceCompatibility = 1.8
		targetCompatibility = 1.8
110
		options.encoding = 'UTF-8'
111
		options.compilerArgs += "-parameters"
J
Juergen Hoeller 已提交
112 113
	}

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

126
	repositories {
B
Brian Clozel 已提交
127
		maven { url "https://repo.spring.io/libs-release" }
128
		maven { url "https://repo.spring.io/milestone" }
129
	}
C
Chris Beams 已提交
130

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

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

171
configure(subprojects - project(":spring-build-src")) { subproject ->
172 173 174
	apply from: "${gradleScriptDir}/publish-maven.gradle"

	jar {
P
Phillip Webb 已提交
175 176
		manifest.attributes["Implementation-Title"] = subproject.name
		manifest.attributes["Implementation-Version"] = subproject.version
177 178 179
		manifest.attributes["Automatic-Module-Name"] = subproject.name.replace('-', '.')  // for Jigsaw
		manifest.attributes["Created-By"] =
				"${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})"
180 181 182 183 184

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

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

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

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

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

	task javadocJar(type: Jar) {
P
Phillip Webb 已提交
213
		classifier = "javadoc"
214 215 216 217 218 219 220
		from javadoc
	}

	artifacts {
		archives sourcesJar
		archives javadocJar
	}
C
Chris Beams 已提交
221 222
}

223
configure(rootProject) {
P
Phillip Webb 已提交
224
	description = "Spring Framework"
225

226
	apply plugin: "groovy"
R
Rob Winch 已提交
227
	apply plugin: "io.spring.dependency-management"
228
	apply from: "${gradleScriptDir}/jdiff.gradle"
229
	apply from: "${gradleScriptDir}/docs.gradle"
230

R
Rob Winch 已提交
231 232 233 234 235 236 237 238 239 240
	dependencyManagement {
		imports {
			mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
		}
		resolutionStrategy {
			cacheChangingModulesFor 0, 'seconds'
		}
		applyMavenExclusions = false
	}

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

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

	artifacts {
		archives docsZip
		archives schemaZip
		archives distZip
	}

	task wrapper(type: Wrapper) {
P
Phillip Webb 已提交
270
		description = "Generates gradlew[.bat] scripts"
271
		gradleVersion = '4.1'
272 273

		doLast() {
274
			def gradleOpts = "-XX:MaxMetaspaceSize=1024m -Xmx1024m"
275
			def gradleBatOpts = "$gradleOpts -XX:MaxHeapSize=256m"
P
Phillip Webb 已提交
276
			File wrapperFile = file("gradlew")
277
			wrapperFile.text = wrapperFile.text.replace("DEFAULT_JVM_OPTS=",
278
					"GRADLE_OPTS=\"$gradleOpts \$GRADLE_OPTS\"\nDEFAULT_JVM_OPTS=")
P
Phillip Webb 已提交
279
			File wrapperBatFile = file("gradlew.bat")
280
			wrapperBatFile.text = wrapperBatFile.text.replace("set DEFAULT_JVM_OPTS=",
281
					"set GRADLE_OPTS=$gradleBatOpts %GRADLE_OPTS%\nset DEFAULT_JVM_OPTS=")
282 283
		}
	}
284

285
}
286 287 288 289 290 291 292 293 294 295 296 297

/*
 * 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-")) {
298
			return version.replace('BUILD', qualifier)
299 300
		}
	}
301
	return version
302
}