-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.gradle
425 lines (364 loc) · 11.7 KB
/
build.gradle
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
419
420
421
422
423
424
425
apply from: 'dependencyDefinitions.gradle'
apply from: 'projectDependencies.gradle'
wrapper {
gradleVersion = '6.8.1'
// TODO:
// maven -> maven-publish
}
def globalSourceCompatibility = 1.8
def globalTargetCompatibility = 1.8
apply plugin: 'idea'
idea {
project {
jdkName = globalSourceCompatibility
languageLevel = globalSourceCompatibility
ipr {
withXml {
def node = it.asNode()
def vcsConfig = node.component.find { it.'@name' == 'VcsDirectoryMappings' }
vcsConfig.mapping[0].'@vcs' = 'Git'
}
}
}
}
import org.gradle.plugins.signing.Sign
buildscript {
project.ext.localReleaseRepoFile = new File("${System.properties.'user.home'}/local-gradle-repository/release")
project.ext.localSnapshotRepoFile = new File("${System.properties.'user.home'}/local-gradle-repository/snapshot")
project.ext.localReleaseRepo = localReleaseRepoFile.toURL().toString()
project.ext.localSnapshotRepo = localSnapshotRepoFile.toURL().toString()
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
url localReleaseRepo
}
maven {
url localSnapshotRepo
}
mavenCentral()
}
dependencies {
// needed for syncSnapshot and syncStaging
classpath 'org.apache.maven.wagon:wagon-webdav-jackrabbit:2.9'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.20.0'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2'
classpath 'me.champeau.gradle:jmh-gradle-plugin:0.5.0'
classpath 'de.thetaphi:forbiddenapis:3.2'
//classpath 'org.kordamp.gradle:jdeps-gradle-plugin:0.3.0'
}
}
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'base'
apply plugin: 'signing'
apply plugin: 'com.github.kt3k.coveralls' // see https://github.com/kt3k/coveralls-gradle-plugin
task javadocAll(type: Javadoc) {
destinationDir = file("$buildDir/javadocAll")
source = files { subprojects.collect { it.sourceSets.main.java } }
classpath = files { subprojects.collect { it.sourceSets.main.compileClasspath } }
// disable doclint for protobuf
// http://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html
// https://github.com/google/protobuf/issues/304
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
task sourceZip(type: Zip) {
classifier = 'sources'
from { subprojects.collect { it.sourceSets.main.allSource } }
}
task javadocZip(type: Zip) {
classifier = 'javadoc'
from javadocAll.outputs.files
}
signing {
required = { !version.endsWith("SNAPSHOT") }
sign javadocZip
sign sourceZip
}
gradle.taskGraph.whenReady { taskGraph ->
if(taskGraph.allTasks.any { it instanceof Sign && it.required }) {
String pgpPassword = System.properties.'pgpPassword'
if(!pgpPassword) {
throw new IllegalStateException('Set pgpPassword system property!')
}
allprojects { ext.'signing.keyId' = '740A1840' }
allprojects { ext.'signing.secretKeyRingFile' = new File("${System.properties['user.home']}/.gnupg/secring.gpg").absolutePath }
allprojects { ext."signing.password" = pgpPassword }
}
}
if(!System.properties.'release' && !System.properties.'prerelease') {
defaultTasks 'build', 'uploadPublished'
} else {
defaultTasks 'build', 'uploadPublished', 'signJavadocZip', 'signSourceZip'
}
allprojects {
apply plugin: 'project-reports'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'jacoco'
group = 'de.huxhorn.sulky'
version = '8.4.0'
def prereleaseIdentifier = System.properties.'prerelease'
if(prereleaseIdentifier) {
version = version + '-' + prereleaseIdentifier
} else if(!System.properties.'release') {
version = version + '-SNAPSHOT'
}
repositories {
maven {
url localReleaseRepo
}
maven {
url localSnapshotRepo
}
mavenCentral()
}
jacoco {
toolVersion = '0.8.7'
}
}
subprojects {
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'de.thetaphi.forbiddenapis'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
//apply plugin: 'org.kordamp.jdeps'
checkstyle {
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
configProperties = [
'configDir': rootProject.file('config/checkstyle'),
'baseDir': rootDir,
]
toolVersion = '9.2'
//ignoreFailures = true
}
pmd {
ruleSetFiles = files(rootProject.file('config/pmd/ruleSet.xml'))
ruleSets = []
toolVersion = '6.41.0'
incrementalAnalysis = true
//ignoreFailures = true
}
forbiddenApis {
bundledSignatures = [
'jdk-unsafe-1.8',
'jdk-deprecated-1.8',
'jdk-internal-1.8',
'jdk-non-portable',
//'jdk-system-out',
'jdk-reflection',
//'commons-io-unsafe-2.5',
]
ignoreFailures = false
//failOnUnresolvableSignatures = false
}
jacocoTestReport {
additionalSourceDirs.from(files(sourceSets.main.allSource.srcDirs))
sourceDirectories.from(files(sourceSets.main.allSource.srcDirs))
classDirectories.from(files(sourceSets.main.output))
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
}
defaultTasks 'build', 'uploadPublished'
sourceCompatibility = globalSourceCompatibility
targetCompatibility = globalTargetCompatibility
// -Xlint:-options disables the
// "warning: [options] bootstrap class path not set in conjunction with -source 1.x"
// for now
def compilerArgs = ['-Xlint:unchecked', '-Xlint:-options', '-Xlint:deprecation', '-g']
compileJava.options.compilerArgs = compilerArgs
compileTestJava.options.compilerArgs = compilerArgs
compileGroovy.options.compilerArgs = compilerArgs
compileTestGroovy.options.compilerArgs = compilerArgs
def sourceEncoding = 'UTF-8'
compileJava.options.encoding = sourceEncoding
compileTestJava.options.encoding = sourceEncoding
compileGroovy.options.encoding = sourceEncoding
compileTestGroovy.options.encoding = sourceEncoding
signing {
required = { !version.endsWith("SNAPSHOT") }
sign configurations.archives
}
task sourceJar(type: Jar) { from sourceSets.main.allSource; classifier = 'sources' }
task javadocJar(type: Jar) { from javadoc.outputs.files; classifier = 'javadoc' }
artifacts { archives sourceJar, javadocJar }
project.ext.defaultProject= {
url 'http://sulky.huxhorn.de'
name project.name
description project.description
inceptionYear '2007'
scm {
connection 'scm:git:git://github.com/huxi/sulky.git'
developerConnection 'scm:git:ssh://[email protected]:huxi/sulky.git'
url 'http://github.com/huxi/sulky/'
}
licenses {
license {
name 'GNU Lesser General Public License v3 (LGPL)'
url 'http://www.gnu.org/copyleft/lesser.html'
distribution 'repo'
}
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
issueManagement {
system 'Github'
url 'https://github.com/huxi/sulky/issues'
}
developers {
developer {
id 'huxhorn'
email '[email protected]'
name 'Joern Huxhorn'
organization = 'Joern Huxhorn'
organizationUrl 'http://sulky.huxhorn.de'
roles {
role 'Developer'
}
}
}
properties {
'project.build.sourceEncoding' 'UTF-8'
'project.reporting.outputEncoding' 'UTF-8'
}
}
configurations {
all*.exclude group: 'commons-logging', module: 'commons-logging'
all*.exclude group: 'org.codehaus.groovy', module: 'groovy-all'
published.extendsFrom archives, signatures
}
dependencies {
testImplementation libraries.'byte-buddy'
testImplementation libraries.'groovy'
testImplementation libraries.'junit'
testImplementation libraries.'slf4j-api'
testImplementation libraries.'spock-core', {
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}
testRuntimeOnly libraries.'logback-classic'
}
def deployer = null
uploadPublished {
deployer = repositories.mavenDeployer {
repository(url: localReleaseRepo)
snapshotRepository(url: localSnapshotRepo)
beforeDeployment { MavenDeployment deployment ->
signing.signPom(deployment)
}
}
}
project.ext.installer = install.repositories.mavenInstaller
installer.pom.project defaultProject
deployer.pom.project defaultProject
}
project(':sulky-version') {
// override for sulky-version after subprojects
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
// source: https://gist.github.com/aalmiray/e6f54aa4b3803be0bcac
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
dependsOn = subprojects.jacocoTestReport
dependsOn = subprojects.test
additionalSourceDirs.from(files(subprojects.sourceSets.main.allSource.srcDirs))
sourceDirectories.from(files(subprojects.sourceSets.main.allSource.srcDirs))
classDirectories.from(files(subprojects.sourceSets.main.output))
executionData.from(files(subprojects.jacocoTestReport.executionData))
reports {
html.enabled = true
xml.enabled = true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
csv.enabled = false
}
onlyIf = {
true
}
doFirst {
executionData = files(executionData.findAll {
it.exists()
})
}
}
coveralls {
jacocoReportPath = "${buildDir}/reports/jacoco/report.xml"
sourceDirs += jacocoRootReport.sourceDirectories
}
allprojects {
tasks.each { task ->
if (task instanceof Javadoc) {
//println task
if (JavaVersion.current().isJava10Compatible()) {
task.options.optionFiles << rootProject.file('config/javadoc10.options')
} else {
task.options.optionFiles << rootProject.file('config/javadoc.options')
}
}
}
}
project.ext.deleteClosure = {
// delete content of it recursively
it.eachDir( deleteClosure );
it.eachFile {
if(it.delete()) {
logger.debug("Deleted ${it.absolutePath}.")
}
}
}
task (group: 'Repository', description: "Cleans the local staging-repository, i.e. '${localReleaseRepoFile.absolutePath}'.", 'cleanStaging') doLast {
deleteClosure(localReleaseRepoFile)
logger.info("Deleted content of ${localReleaseRepoFile.absolutePath}.")
}
task (group: 'Repository', description: "Cleans the local SNAPSHOT-repository, i.e. '${localSnapshotRepoFile.absolutePath}'.", 'cleanSnapshot') doLast {
deleteClosure(localSnapshotRepoFile)
logger.info("Deleted content of ${localReleaseRepoFile.absolutePath}.")
}
task (group: 'Repository', description: 'Sync local staging-repository to oss.sonatype.org.', 'syncStaging') doLast {
if (project.hasProperty('remoteUsername') && project.hasProperty('remotePassword')) {
def stagingRepos = new org.apache.maven.wagon.repository.Repository('staging', 'https://oss.sonatype.org/service/local/staging/deploy/maven2')
def auth = new org.apache.maven.wagon.authentication.AuthenticationInfo()
auth.userName = remoteUsername
auth.password = remotePassword
def wagon = new org.apache.maven.wagon.providers.webdav.WebDavWagon()
wagon.connect(stagingRepos, auth)
localReleaseRepoFile.eachFile {
if (it.directory) {
wagon.putDirectory(it, it.name)
} else {
wagon.put(it, it.name)
}
}
} else {
println "Can't sync staging as credentials aren't set. Set with -PremoteUsername=user -PremotePassword=password."
}
}
task (group: 'Repository', description: 'Sync local SNAPSHOT-repository to oss.sonatype.org.', 'syncSnapshot') doLast {
if (project.hasProperty('remoteUsername') && project.hasProperty('remotePassword')) {
def snapshotRepos = new org.apache.maven.wagon.repository.Repository('snapshot', 'https://oss.sonatype.org/content/repositories/snapshots')
def auth = new org.apache.maven.wagon.authentication.AuthenticationInfo()
auth.userName = remoteUsername
auth.password = remotePassword
def wagon = new org.apache.maven.wagon.providers.webdav.WebDavWagon()
wagon.connect(snapshotRepos, auth)
localSnapshotRepoFile.eachFile {
if (it.directory) {
wagon.putDirectory(it, it.name)
} else {
wagon.put(it, it.name)
}
}
} else {
println "Can't sync snapshots as credentials aren't set. Set with -PremoteUsername=user -PremotePassword=password."
}
}
apply plugin: 'detect-split-packages'