build.gradle 10.3 KB
Newer Older
1
buildscript {
2
	repositories {
3
		maven { url "https://repo.spring.io/plugins-release" }
4 5
	}
	dependencies {
B
Brian Clozel 已提交
6
		classpath("io.spring.gradle:propdeps-plugin:0.0.9.RELEASE")
7
		classpath("org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16")
8
	}
9 10
}

11
// 3rd party plugin repositories can be configured in settings.gradle
12
plugins {
B
Brian Clozel 已提交
13
	id "io.spring.dependency-management" version "1.0.5.RELEASE" apply false
J
Juergen Hoeller 已提交
14
	id "org.jetbrains.kotlin.jvm" version "1.2.50" apply false
S
Sebastien Deleuze 已提交
15
	id "org.jetbrains.dokka" version "0.9.17"
B
Brian Clozel 已提交
16
	id "org.asciidoctor.convert" version "1.5.7"
B
Brian Clozel 已提交
17 18
}

S
Stephane Nicoll 已提交
19 20 21 22 23 24
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'
25
	linkScmDevConnection = 'scm:git:ssh://git@github.com:spring-projects/spring-framework.git'
26

27
	moduleProjects = subprojects.findAll {
28 29
		!it.name.equals('spring-build-src') && !it.name.equals('spring-framework-bom')
	}
30 31 32 33 34

	aspectjVersion       = "1.9.1"
	freemarkerVersion    = "2.3.28"
	groovyVersion        = "2.5.0"
	hsqldbVersion        = "2.4.1"
J
Juergen Hoeller 已提交
35
	jackson2Version      = "2.9.6"
36 37 38 39
	jettyVersion         = "9.4.11.v20180605"
	junitPlatformVersion = "1.2.0"
	junitJupiterVersion  = "5.2.0"
	junitVintageVersion  = "5.2.0"
J
Juergen Hoeller 已提交
40
	kotlinVersion        = "1.2.50"
41 42 43 44 45
	log4jVersion         = "2.11.0"
	nettyVersion         = "4.1.25.Final"
	reactorVersion       = "Californium-BUILD-SNAPSHOT"
	rxjavaVersion        = "1.3.8"
	rxjavaAdapterVersion = "1.2.1"
J
Juergen Hoeller 已提交
46
	rxjava2Version       = "2.1.15"
47 48 49 50 51 52 53 54 55
	slf4jVersion         = "1.7.25"	  // spring-jcl + consistent 3rd party deps
	tiles3Version        = "3.0.8"
	tomcatVersion        = "9.0.8"
	undertowVersion      = "2.0.9.Final"

	gradleScriptDir = "${rootProject.projectDir}/gradle"
	withoutJclOverSlf4J = {
		exclude group: "org.slf4j", module: "jcl-over-slf4j"
	}
S
Stephane Nicoll 已提交
56 57
}

C
Chris Beams 已提交
58
configure(allprojects) { project ->
59 60
	group = "org.springframework"
	version = qualifyVersionIfNecessary(version)
61

62
	apply plugin: "propdeps"
P
Phillip Webb 已提交
63
	apply plugin: "java"
64
	apply plugin: "test-source-set-dependencies"
65
	apply plugin: "io.spring.dependency-management"
66
	apply from: "${gradleScriptDir}/ide.gradle"
C
Chris Beams 已提交
67

68 69 70 71 72 73 74 75 76 77
	dependencyManagement {
		resolutionStrategy {
			cacheChangingModulesFor 0, 'seconds'
		}
		applyMavenExclusions = false
		generatedPomCustomization {
			enabled = false
		}
	}

S
Sebastien Deleuze 已提交
78 79
	apply plugin: "kotlin"
	compileKotlin {
S
sdeleuze 已提交
80 81
		kotlinOptions {
			jvmTarget = "1.8"
82
			freeCompilerArgs = ["-Xjsr305=strict"]
S
sdeleuze 已提交
83 84 85
			apiVersion = "1.1"
			languageVersion = "1.1"
		}
S
Sebastien Deleuze 已提交
86 87
	}
	compileTestKotlin {
S
sdeleuze 已提交
88 89
		kotlinOptions {
			jvmTarget = "1.8"
90
			freeCompilerArgs = ["-Xjsr305=strict"]
S
sdeleuze 已提交
91
		}
S
Sebastien Deleuze 已提交
92 93
	}

94
	configurations.all {
J
Juergen Hoeller 已提交
95
		// Check for updates every build
96
		resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
97 98 99 100 101 102 103 104

		// Consistent slf4j version (e.g. clashes between slf4j versions)
		resolutionStrategy.eachDependency { DependencyResolveDetails details ->
			if (details.requested.group == 'org.slf4j') {
				details.useVersion slf4jVersion
			}
		}

105 106
	}

107 108 109 110
	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 已提交
111

112 113 114
	compileJava.options*.compilerArgs = commonCompilerArgs +
			["-Xlint:varargs", "-Xlint:fallthrough", "-Xlint:rawtypes",
			 "-Xlint:deprecation", "-Xlint:unchecked", "-Werror"]
B
Brian Clozel 已提交
115

116 117 118
	compileTestJava.options*.compilerArgs = commonCompilerArgs +
			["-Xlint:-varargs", "-Xlint:-fallthrough","-Xlint:-rawtypes",
			 "-Xlint:-deprecation", "-Xlint:-unchecked"]
P
Phillip Webb 已提交
119

120
	compileJava {
121
		sourceCompatibility = 1.8  // can be switched to 10 for testing
122
		targetCompatibility = 1.8
123
		options.encoding = 'UTF-8'
124 125 126
	}

	compileTestJava {
127
		sourceCompatibility = 1.8  // can be switched to 10 for testing
J
Juergen Hoeller 已提交
128
		targetCompatibility = 1.8
129
		options.encoding = 'UTF-8'
130
		options.compilerArgs += "-parameters"
J
Juergen Hoeller 已提交
131 132
	}

C
Chris Beams 已提交
133 134
	test {
		systemProperty("java.awt.headless", "true")
135
		systemProperty("testGroups", project.properties.get("testGroups"))
136
		scanForTestClasses = false
137
		include(["**/*Tests.class", "**/*Test.class"])
138 139
		// Since we set scanForTestClasses to false, we need to filter out inner
		// classes with the "$" pattern; otherwise, using -Dtest.single=MyTests to
140
		// run MyTests by itself will fail if MyTests contains any inner classes.
141
		exclude(["**/Abstract*.class", '**/*$*'])
B
Brian Clozel 已提交
142
		reports.junitXml.setDestination(file("$buildDir/test-results"))
C
Chris Beams 已提交
143
	}
C
Chris Beams 已提交
144

145
	repositories {
B
Brian Clozel 已提交
146
		maven { url "https://repo.spring.io/libs-release" }
147
		maven { url "https://repo.spring.io/snapshot" }  // for Reactor
148
	}
C
Chris Beams 已提交
149

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

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

191
configure(subprojects - project(":spring-build-src")) { subproject ->
192 193 194
	apply from: "${gradleScriptDir}/publish-maven.gradle"

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

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

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

212 213 214
		options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
		options.author = true
		options.header = project.name
215
		options.use = true
C
Chris Beams 已提交
216
		options.links(project.ext.javadocLinks)
217
		options.addStringOption('Xdoclint:none', '-quiet')
C
Chris Beams 已提交
218

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

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

	task javadocJar(type: Jar) {
P
Phillip Webb 已提交
233
		classifier = "javadoc"
234 235 236 237 238 239 240
		from javadoc
	}

	artifacts {
		archives sourcesJar
		archives javadocJar
	}
C
Chris Beams 已提交
241 242
}

243
configure(rootProject) {
P
Phillip Webb 已提交
244
	description = "Spring Framework"
245

246
	apply plugin: "groovy"
247
	apply from: "${gradleScriptDir}/jdiff.gradle"
248
	apply from: "${gradleScriptDir}/docs.gradle"
249

R
Rob Winch 已提交
250 251 252 253 254 255
	dependencyManagement {
		imports {
			mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
		}
	}

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

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

	artifacts {
		archives docsZip
		archives schemaZip
		archives distZip
	}

S
Sam Brannen 已提交
284
	wrapper {
P
Phillip Webb 已提交
285
		description = "Generates gradlew[.bat] scripts"
J
Juergen Hoeller 已提交
286
		gradleVersion = '4.8.1'
287 288

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

300
}
301 302 303 304 305 306 307 308 309 310 311 312

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