build.gradle 10.4 KB
Newer Older
1
buildscript {
2
	repositories {
3
		maven { url 'https://repo.spring.io/plugins-release' }
4 5
	}
	dependencies {
6 7
		classpath('io.spring.gradle:propdeps-plugin:0.0.9.RELEASE')
		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 {
13 14 15 16
	id 'io.spring.dependency-management' version '1.0.5.RELEASE' apply false
	id 'org.jetbrains.kotlin.jvm' version '1.2.60' apply false
	id 'org.jetbrains.dokka' version '0.9.17'
	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 35 36
	aspectjVersion       = '1.9.1'
	freemarkerVersion    = '2.3.28'
	groovyVersion        = '2.5.2'
	hsqldbVersion        = '2.4.1'
	jackson2Version      = '2.9.6'
	jettyVersion         = '9.4.12.RC1'
37
	junit5Version        = '5.3.0-RC1'
38 39 40
	kotlinVersion        = '1.2.60'
	log4jVersion         = '2.11.1'
	nettyVersion         = '4.1.28.Final'
41
	reactorVersion       = 'Californium-M2'
42 43 44 45 46 47 48
	rxjavaVersion        = '1.3.8'
	rxjavaAdapterVersion = '1.2.1'
	rxjava2Version       = '2.2.0'
	slf4jVersion         = '1.7.25'	  // spring-jcl + consistent 3rd party deps
	tiles3Version        = '3.0.8'
	tomcatVersion        = '9.0.10'
	undertowVersion      = '2.0.12.Final'
49 50 51

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

C
Chris Beams 已提交
56
configure(allprojects) { project ->
57
	group = 'org.springframework'
58
	version = qualifyVersionIfNecessary(version)
59

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

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

P
Phillip Webb 已提交
77
	checkstyle {
78 79
		toolVersion = '8.10.1'
		configDir = rootProject.file('src/checkstyle')
P
Phillip Webb 已提交
80 81
	}

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

98
	configurations.all {
J
Juergen Hoeller 已提交
99
		// Check for updates every build
100
		resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
101 102 103 104 105 106 107 108

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

109 110
	}

111
	def commonCompilerArgs =
112 113 114
			['-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 已提交
115

116
	compileJava.options*.compilerArgs = commonCompilerArgs +
117 118
			['-Xlint:varargs', '-Xlint:fallthrough', '-Xlint:rawtypes',
			 '-Xlint:deprecation', '-Xlint:unchecked', '-Werror']
B
Brian Clozel 已提交
119

120
	compileTestJava.options*.compilerArgs = commonCompilerArgs +
121 122
			['-Xlint:-varargs', '-Xlint:-fallthrough', '-Xlint:-rawtypes',
			 '-Xlint:-deprecation', '-Xlint:-unchecked']
P
Phillip Webb 已提交
123

124
	compileJava {
125
		sourceCompatibility = 1.8  // can be switched to 10 for testing
126
		targetCompatibility = 1.8
127
		options.encoding = 'UTF-8'
128 129 130
	}

	compileTestJava {
131
		sourceCompatibility = 1.8  // can be switched to 10 for testing
J
Juergen Hoeller 已提交
132
		targetCompatibility = 1.8
133
		options.encoding = 'UTF-8'
134
		options.compilerArgs += '-parameters'
J
Juergen Hoeller 已提交
135 136
	}

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

149
	repositories {
150 151
		maven { url 'https://repo.spring.io/libs-release' }
		maven { url 'https://repo.spring.io/milestone' }  // for Reactor
152
	}
C
Chris Beams 已提交
153

154
	dependencies {
155
		testCompile('junit:junit:4.12') {
156 157
			exclude group:'org.hamcrest', module:'hamcrest-core'
		}
158
		testCompile('org.mockito:mockito-core:2.21.0') {
159 160
			exclude group:'org.hamcrest', module:'hamcrest-core'
		}
161
		testCompile('com.nhaarman:mockito-kotlin:1.6.0') {
S
Sebastien Deleuze 已提交
162 163 164 165
			exclude module:'kotlin-stdlib'
			exclude module:'kotlin-reflect'
			exclude module:'mockito-core'
		}
166
		testCompile('org.hamcrest:hamcrest-all:1.3')
167
		testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}")
168 169
		testRuntime("org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}")
		testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}")
P
Phillip Webb 已提交
170
		// JSR-305 only used for non-required meta-annotations
171 172 173
		compileOnly('com.google.code.findbugs:jsr305:3.0.2')
		testCompileOnly('com.google.code.findbugs:jsr305:3.0.2')
		checkstyle('io.spring.javaformat:spring-javaformat-checkstyle:0.0.5')
174
	}
C
Chris Beams 已提交
175 176

	ext.javadocLinks = [
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
		'http://docs.oracle.com/javase/8/docs/api/',
		'http://docs.oracle.com/javaee/7/api/',
		'http://docs.oracle.com/cd/E13222_01/wls/docs90/javadocs/',  // CommonJ
		'http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.javadoc.doc/web/apidocs/',
		'http://glassfish.java.net/nonav/docs/v3/api/',
		'http://docs.jboss.org/jbossas/javadoc/4.0.5/connector/',
		'http://docs.jboss.org/jbossas/javadoc/7.1.2.Final/',
		'http://tiles.apache.org/tiles-request/apidocs/',
		'http://tiles.apache.org/framework/apidocs/',
		'http://www.eclipse.org/aspectj/doc/released/aspectj5rt-api/',
		'http://ehcache.org/apidocs/2.10.4',
		'http://quartz-scheduler.org/api/2.2.1/',
		'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/',
		'http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/'
C
Chris Beams 已提交
193
	] as String[]
194 195
}

196
configure(subprojects - project(':spring-build-src')) { subproject ->
197 198 199
	apply from: "${gradleScriptDir}/publish-maven.gradle"

	jar {
200 201 202 203 204
		manifest.attributes['Implementation-Title'] = subproject.name
		manifest.attributes['Implementation-Version'] = subproject.version
		manifest.attributes['Automatic-Module-Name'] = subproject.name.replace('-', '.')  // for Jigsaw
		manifest.attributes['Created-By'] =
				"${System.getProperty('java.version')} (${System.getProperty('java.specification.vendor')})"
205

206
		from("${rootProject.projectDir}/src/docs/dist") {
207 208 209 210
			include 'license.txt'
			include 'notice.txt'
			into 'META-INF'
			expand(copyright: new Date().format('yyyy'), version: project.version)
211 212 213 214
		}
	}

	javadoc {
215
		description = 'Generates project-level javadoc for use in -javadoc jar'
C
Chris Beams 已提交
216

217 218 219
		options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
		options.author = true
		options.header = project.name
220
		options.use = true
C
Chris Beams 已提交
221
		options.links(project.ext.javadocLinks)
222
		options.addStringOption('Xdoclint:none', '-quiet')
C
Chris Beams 已提交
223

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

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

	task javadocJar(type: Jar) {
238
		classifier = 'javadoc'
239 240 241 242 243 244 245
		from javadoc
	}

	artifacts {
		archives sourcesJar
		archives javadocJar
	}
C
Chris Beams 已提交
246 247
}

248
configure(rootProject) {
249
	description = 'Spring Framework'
250

251
	apply plugin: 'groovy'
252
	apply from: "${gradleScriptDir}/jdiff.gradle"
253
	apply from: "${gradleScriptDir}/docs.gradle"
254

R
Rob Winch 已提交
255 256 257 258 259 260
	dependencyManagement {
		imports {
			mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
		}
	}

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

264
	dependencies {  // for integration tests
265 266 267 268 269 270 271 272 273 274 275 276 277
		testCompile(project(':spring-aop'))
		testCompile(project(':spring-beans'))
		testCompile(project(':spring-context'))
		testCompile(project(':spring-core'))
		testCompile(project(':spring-expression'))
		testCompile(project(':spring-jdbc'))
		testCompile(project(':spring-orm'))
		testCompile(project(':spring-test'))
		testCompile(project(':spring-tx'))
		testCompile(project(':spring-web'))
		testCompile('javax.inject:javax.inject:1')
		testCompile('javax.resource:javax.resource-api:1.7.1')
		testCompile('javax.servlet:javax.servlet-api:3.1.0')
278
		testCompile("org.aspectj:aspectjweaver:${aspectjVersion}")
P
Phillip Webb 已提交
279
		testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
280
		testCompile('org.hibernate:hibernate-core:5.1.15.Final')
281 282 283 284 285 286 287 288
	}

	artifacts {
		archives docsZip
		archives schemaZip
		archives distZip
	}

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

302
}
303 304 305 306 307 308 309 310 311

/*
 * 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) {
312 313 314
	if (rootProject.hasProperty('BRANCH_NAME')) {
		def qualifier = rootProject.getProperty('BRANCH_NAME')
		if (qualifier.startsWith('SPR-')) {
315
			return version.replace('BUILD', qualifier)
316 317
		}
	}
318
	return version
319
}