Codebase list libjxmpp-java / 4548cbe1-e57b-41d9-a93f-45f7fd86df29/main build.gradle
4548cbe1-e57b-41d9-a93f-45f7fd86df29/main

Tree @4548cbe1-e57b-41d9-a93f-45f7fd86df29/main (Download .tar.gz)

build.gradle @4548cbe1-e57b-41d9-a93f-45f7fd86df29/mainraw · history · blame

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
buildscript {
	repositories {
		maven {
			url "https://plugins.gradle.org/m2/"
		}
		mavenCentral()
	}

	dependencies {
		classpath "org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2"
	}
}

plugins {
	id 'ru.vyarus.animalsniffer' version '1.5.0'
	id 'net.ltgt.errorprone' version '0.8.1'
	id 'me.champeau.gradle.jmh' version '0.4.8'
}

allprojects {
	apply plugin: 'java'
	apply plugin: 'eclipse'
	apply plugin: 'idea'
	apply plugin: 'jacoco'

	repositories {
		mavenLocal()
		mavenCentral()
	}

	version readVersionFile()

	ext {
		isSnapshot = version.endsWith('-SNAPSHOT')
		gitCommit = getGitCommit()
		javadocAllDir = new File(buildDir, 'javadoc')
		documentationDir = new File(projectDir, 'documentation')
		releasedocsDir = new File(buildDir, 'releasedocs')
		rootConfigDir = new File(rootDir, 'config')
		sonatypeCredentialsAvailable = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
		isReleaseVersion = !isSnapshot
		isContinuousIntegrationEnvironment = Boolean.parseBoolean(System.getenv('CI'))
		signingRequired = !(isSnapshot || isContinuousIntegrationEnvironment)
		sonatypeSnapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
		sonatypeStagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
		builtDate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date())
		oneLineDesc = 'An Open Source XMPP (Jabber) library'
		androidProjects = [':jxmpp-core', ':jxmpp-jid', ':jxmpp-stringprep-libidn', ':jxmpp-util-cache'].collect{ project(it) }
		jmhProjects = [':jxmpp-util-cache'].collect { project(it) }
		junit4Projects = [
			':jxmpp-core',
			':jxmpp-jid',
			':jxmpp-repl',
			':jxmpp-stringprep-icu4j',
			':jxmpp-stringprep-libidn',
			':jxmpp-util-cache',
		].collect { project(it) }
		// Only enable Error Prone for non JMH projects, as JMH
		// uses generated Java source code which is prone to Error
		// Prone bug patterns.
		errorProneProjects = subprojects - project(":jxmpp-util-cache")
		junitVersion = '5.6.1'
		javaCompatilibity = JavaVersion.VERSION_1_8
		javaMajor = javaCompatilibity.getMajorVersion()
		jxmppMinAndroidSdk = 19
	}

	group = 'org.jxmpp'
	sourceCompatibility = javaCompatilibity
	targetCompatibility = sourceCompatibility

	ext.sharedManifest = manifest {
		attributes('Implementation-Version': version,
				   'Implementation-GitRevision': ext.gitCommit,
				   'Built-Date': ext.builtDate,
				   'Built-JDK': System.getProperty('java.version'),
				   'Built-Gradle': gradle.gradleVersion,
				   'Built-By': System.getProperty('user.name')
				  )
	}

	eclipse {
		classpath {
			downloadJavadoc = true
		}
	}

	// Make all project's 'test' target depend on javadoc, so that
	// javadoc is also linted.
	test.dependsOn javadoc

	tasks.withType(JavaCompile) {
		// Some systems may not have set their platform default
		// converter to 'utf8', but we use unicode in our source
		// files. Therefore ensure that javac uses unicode
		options.encoding = "utf8"
		options.compilerArgs = [
			'-Xlint:all',
			// Set '-options' because a non-java7 javac will emit a
			// warning if source/target is set to 1.7 and
			// bootclasspath is *not* set.
			'-Xlint:-options',
			'-Werror',
		]
	}
	if (JavaVersion.current().isJava8Compatible()) {
		tasks.withType(Javadoc) {
			// The '-quiet' as second argument is actually a hack,
			// since the one parameter addStringOption doesn't seem to
			// work, we extra add '-quiet', which is added anyway by
			// gradle.
			options.addStringOption('Xdoclint:all', '-quiet')
			// Abort on javadoc warnings.
			// See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363)
			// for information about the -Xwerror option.
			options.addStringOption('Xwerror', '-quiet')
		}
	}

	if (JavaVersion.current().isJava9Compatible()) {
		tasks.withType(Javadoc) {
			options.addStringOption('-release', javaMajor)
		}
		tasks.withType(JavaCompile) {
			options.compilerArgs.addAll([
				'--release', javaMajor,
			])
		}
	}

	tasks.withType(Javadoc) {
		options.charSet = "UTF-8"
	}

	jacoco {
		toolVersion = "0.8.3"
	}

	jacocoTestReport {
		dependsOn test
		getSourceDirectories().setFrom(project.files(sourceSets.main.allSource.srcDirs))
		getClassDirectories().setFrom(project.files(sourceSets.main.output))
		reports {
			xml.enabled true
		}
	}

	dependencies {
		testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
		testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
	}

	test {
		useJUnitPlatform()
		// Enable full stacktraces of failed tests. Especially handy
		// for environments like Travis.
		testLogging {
			events "failed"
			exceptionFormat "full"
		}
	}
}

task javadocAll(type: Javadoc) {
	source subprojects.collect {project ->
		project.sourceSets.main.allJava }
	destinationDir = javadocAllDir
	// Might need a classpath
	classpath = files(subprojects.collect {project ->
		project.sourceSets.main.compileClasspath})
	options.linkSource = true
	options.use = true
	options.links = ["https://docs.oracle.com/javase/${javaMajor}/docs/api/"] as String[]
}

task distributionZip(type: Zip, dependsOn: [javadocAll]) {
	classifier builtDate
	into ('javadoc') {
		from(javadocAllDir)
	}
}

jar {
	// Root project should not create empty jar artifact
	enabled = false
}

description = """\
JXMPP ${version}
${oneLineDesc}."""

// Disable uploadArchives task for the root project
uploadArchives.enabled = false

evaluationDependsOnChildren()
subprojects {
	apply plugin: 'maven-publish'
	apply plugin: 'signing'
	apply plugin: 'checkstyle'

	checkstyle {
		toolVersion = '8.22'
	}
	task sourcesJar(type: Jar, dependsOn: classes) {
		classifier = 'sources'
		from sourceSets.main.allSource
	}
	task javadocJar(type: Jar, dependsOn: javadoc) {
		classifier = 'javadoc'
		from javadoc.destinationDir
	}
	task testsJar(type: Jar) {
		classifier = 'tests'
		from sourceSets.test.output
	}
	artifacts {
		// See http://stackoverflow.com/a/21946676/194894
		testRuntime testsJar
	}

	publishing {
		publications {
			mavenJava(MavenPublication) {
				from components.java
				artifact sourcesJar
				artifact javadocJar
				artifact testsJar
				pom {
					name = 'JXMPP'
					packaging = 'jar'
					inceptionYear = '2014'
					url = 'http://www.igniterealtime.org/projects/jxmpp/'
					description = project.description

					issueManagement {
						system = 'JIRA'
						url = 'http://issues.igniterealtime.org/browse/JXMPP'
					}

					scm {
						url = 'https://github.com/igniterealtime/Smack'
						connection = 'scm:git:https://github.com/igniterealtime/Smack.git'
						developerConnection = 'scm:git:https://github.com/igniterealtime/Smack.git'
					}

					licenses {
						license {
							name = 'The Apache Software License, Version 2.0'
							url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
							distribution = 'repo'
						}
					}

					developers {
						developer {
							id = 'flow'
							name = 'Florian Schmaus'
							email = 'flow@igniterealtime.org'
						}
					}
				}
			}
		}
		repositories {
			maven {
				url isSnapshot ? sonatypeSnapshotUrl : sonatypeStagingUrl
				if (sonatypeCredentialsAvailable) {
					credentials {
						username = sonatypeUsername
						password = sonatypePassword
					}
				}
			}
		}
	}
	rootProject.distributionZip {
		dependsOn build
		from(buildDir) {
			include "$libsDirName/**"
		}
	}

	// Workaround for gpg signatory not supporting the 'required' option
	// See https://github.com/gradle/gradle/issues/5064#issuecomment-381924984
	// Note what we use 'signing.gnupg.keyName' instead of 'signing.keyId'.
	tasks.withType(Sign) {
		onlyIf {
			project.hasProperty('signing.gnupg.keyName')
		}
	}
	signing {
		required { signingRequired }
		useGpgCmd()
		sign publishing.publications.mavenJava
	}
}

configure (errorProneProjects) {
	apply plugin: 'net.ltgt.errorprone'

	tasks.withType(JavaCompile) {
		options.errorprone {
			error(
				"UnusedVariable",
				"UnusedMethod",
				"MethodCanBeStatic",
			)
			errorproneArgs = [
				// Disable MissingCasesInEnumSwitch error prone check
				// because this check is already done by javac as incomplete-switch.
				'-Xep:MissingCasesInEnumSwitch:OFF',
				'-Xep:StringSplitter:OFF',
				'-Xep:JavaTimeDefaultTimeZone:OFF',
			]
		}
	}

	dependencies {
		errorprone 'com.google.errorprone:error_prone_core:2.3.3'
		errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
	}
}

dependencies {
	androidProjects.each { project ->
		compile project
	}
}

configure (junit4Projects) {
	dependencies {
		testImplementation "junit:junit:4.12"
		testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junitVersion"
	}
}

configure (androidProjects) {
    apply plugin: 'ru.vyarus.animalsniffer'
    dependencies {
        signature "net.sf.androidscents.signature:android-api-level-${jxmppMinAndroidSdk}:4.4.2_r4@signature"
    }
    animalsniffer {
        sourceSets = [sourceSets.main]
    }
}

configure (jmhProjects) {
	apply plugin: "me.champeau.gradle.jmh"

	// From https://github.com/melix/jmh-gradle-plugin/issues/35
	// This should be theoretically not be needed with newer jmh
	// gradle plugin versions. But without the following line "gradle
	// eclipse" will add the jmh dependencies to the classpath
	// TODO: This breaks with parboiled and is thus commented out.
	// project.eclipse.classpath.plusConfigurations += [ configurations.jmh ]

	jmh {
		jmhVersion '1.21'
		iterations 3
		operationsPerInvocation 3
		fork 3
	}
}

apply plugin: "com.github.kt3k.coveralls"
coveralls {
	sourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs).files.absolutePath
}

task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
	dependsOn = subprojects.jacocoTestReport
	getSourceDirectories().setFrom(files(subprojects.sourceSets.main.allSource.srcDirs))
	getClassDirectories().setFrom(files(subprojects.sourceSets.main.output))
	getExecutionData().setFrom(files(subprojects.jacocoTestReport.executionData))
	reports {
		xml.enabled true
		xml.destination file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
	}
	// We could remove the following setOnlyIf line, but then
	// jacocoRootReport would silently be SKIPPED if something with
	// the subprojects is wrong (e.g. a project is missing
	// in there).
	setOnlyIf { true }
}

def getGitCommit() {
	def projectDirFile = new File("$projectDir")
	def dotGit = new File(projectDirFile, ".git")
	if (!dotGit.isDirectory()) return 'non-git build'

	def cmd = 'git describe --always --tags --dirty=+'
	def proc = cmd.execute(null, projectDirFile)
	def gitCommit = proc.text.trim()
	assert !gitCommit.isEmpty()
	gitCommit
}

def getAndroidRuntimeJar() {
	def androidHome = new File("$System.env.ANDROID_HOME")
	if (!androidHome.isDirectory()) throw new Exception("ANDROID_HOME not found or set")
	def androidJar = new File("$androidHome/platforms/android-$jxmppMinAndroidSdk/android.jar")
	if (androidJar.isFile()) {
		return androidJar
	} else {
		throw new Exception("Can't find android.jar for $jxmppMinAndroidSdk API. Please install corresponding SDK platform package")
	}
}

def readVersionFile() {
	def versionFile = new File(rootDir, 'version')
	if (!versionFile.isFile()) {
		throw new Exception("Could not find version file")
	}
	if (versionFile.text.isEmpty()) {
		throw new Exception("Version file does not contain a version")
	}
	versionFile.text.trim()
}