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
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"
R
Rossen Stoyanchev 已提交
56
	ext.reactorVersion       = "Bismuth-SR5"
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.27"
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
		maven { url "https://repo.spring.io/milestone" }  // for AspectJ 1.9 beta
135
	}
C
Chris Beams 已提交
136

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	artifacts {
		archives docsZip
		archives schemaZip
		archives distZip
	}

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

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

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

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