forked from huxi/lilith
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
599 lines (518 loc) · 17.2 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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
buildscript {
apply from: 'dependencyDefinitions.gradle'
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 {
maven {
url localReleaseRepo
}
maven {
url localSnapshotRepo
}
jcenter()
mavenCentral()
mavenLocal()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
// needed for syncSnapshot and syncStaging
classpath 'org.apache.maven.wagon:wagon-webdav-jackrabbit:2.9'
classpath 'de.huxhorn.gradle:de.huxhorn.gradle.git-state-plugin:0.0.2'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.7.1'
classpath 'gradle.plugin.edu.sc.seis:macAppBundle:2.1.6'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
classpath 'de.thetaphi:forbiddenapis:2.3'
}
}
apply from: 'dependencyDefinitions.gradle'
apply from: 'projectDependencies.gradle'
import org.apache.tools.ant.filters.FixCrLfFilter
import org.gradle.plugins.signing.Sign
task wrapper(type: Wrapper) {
gradleVersion = '3.4'
}
def copyright = "Copyright \u00a9 2007-2017 J\u00f6rn Huxhorn"
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'
}
}
}
}
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/javadoc")
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) {
// name clash with org.gradle.api.tasks.Console
java.io.Console console = System.console()
if(!console) {
throw new IllegalStateException('System.console() returned null. Restart with --no-daemon.')
}
pgpPassword = new String(console.readPassword("\nPGP Private Key Password: "))
}
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', 'shadowJar', 'myDistZip', 'myDistTgz', 'appTgz'
} else {
defaultTasks 'build', 'uploadPublished', 'shadowJar', 'myDistZip', 'myDistTgz', 'appTgz', 'signJavadocZip', 'signSourceZip'
}
allprojects {
apply plugin: 'project-reports'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'jacoco'
group = 'de.huxhorn.lilith'
version = '8.1.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()
mavenLocal()
}
jacoco {
toolVersion = '0.7.9'
}
task printConfig doLast {
configurations.each { config ->
println "Configuration " + config.name
config.allArtifacts.each {
println "\t${it}"
println "\t\t${it.name}"
println "\t\t${it.file}"
println "\t\t${it.buildDependencies.values}"
}
println "------"
}
}
}
subprojects {
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'de.thetaphi.forbiddenapis'
apply plugin: 'checkstyle'
checkstyle {
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
configProperties = [
'configDir': rootProject.file('config/checkstyle'),
'baseDir': rootDir,
]
toolVersion = '7.5.1'
//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 = files(sourceSets.main.allSource.srcDirs)
sourceDirectories = files(sourceSets.main.allSource.srcDirs)
classDirectories = 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
javadoc.options.encoding = sourceEncoding
signing {
required = { !version.endsWith("SNAPSHOT") }
sign configurations.archives
}
boolean gpl=['lilith', 'lilith-conditions', 'lilith-engine', 'lilith-xml-logging'].contains(project.name)
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://lilithapp.com'
name project.name
description project.description
inceptionYear '2007'
scm {
connection 'scm:git:git://github.com/huxi/lilith.git'
developerConnection 'scm:git:ssh://[email protected]:huxi/lilith.git'
url 'http://github.com/huxi/lilith/'
}
licenses {
if(gpl)
{
license {
name 'GNU General Public License v3 (GPL)'
url 'http://www.gnu.org/licenses/gpl.html'
distribution 'repo'
}
}
else
{
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/lilith/issues'
}
developers {
developer {
id 'huxhorn'
email '[email protected]'
name 'Joern Huxhorn'
organization = 'Joern Huxhorn'
organizationUrl 'http://lilithapp.com'
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 {
testCompile libraries.'groovy'
testCompile libraries.'spock-core', {
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}
testCompile libraries.junit
testCompile libraries.'slf4j-api'
testRuntime libraries.'logback-classic'
}
jar {
manifest.attributes provider: 'gradle'
}
def deployer = null
uploadPublished {
deployer = repositories.mavenDeployer {
repository(url: localReleaseRepo)
snapshotRepository(url: localSnapshotRepo)
beforeDeployment { MavenDeployment deployment ->
signing.signPom(deployment)
}
}
}
def installer = install.repositories.mavenInstaller
installer.pom.project defaultProject
deployer.pom.project defaultProject
}
project(':lilith') {
apply plugin: 'application'
apply plugin: de.huxhorn.gradle.git.GitStatePlugin
apply plugin: 'edu.sc.seis.macAppBundle'
apply plugin: 'com.github.johnrengelman.shadow'
/*
### macappbundle
- [Gradle Plugin Homepage](https://github.com/crotwell/gradle-macappbundle/)
- [MacAppBundlePluginExtension](https://github.com/crotwell/gradle-macappbundle/blob/master/src/main/groovy/edu/sc/seis/macAppBundle/MacAppBundlePluginExtension.groovy)
- Artifact: `'gradle.plugin.edu.sc.seis:macAppBundle:2.1.1'`
- http://kovuthehusky.com/blog/running-minecraft-on-os-x-using-java-7/
- https://bugs.mojang.com/browse/MCL-1049
- https://bugs.mojang.com/browse/MCL-2628
- https://gist.github.com/pudquick/7518753
- http://docs.oracle.com/javase/8/docs/technotes/guides/deploy/package_for_mac.html
- https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Optimizing/Optimizing.html
*/
if(!System.properties.'ignoreGit' && (System.properties.'release' || System.properties.'prerelease')) {
project.git.requireClean = true
processResources.dependsOn checkGitState
}
//def theMainClassName = 'de.huxhorn.lilith.Lilith'
def theMainClassName = 'de.huxhorn.sulky.version.Main'
mainClassName = theMainClassName
macAppBundle {
mainClassName = theMainClassName
appName = 'Lilith' // ends up in CFBundleName
bundleIdentifier = 'de.huxhorn.lilith'
creatorCode = 'Llth'
//jvmVersion = '1.8+'
//jvmVersion is AppleJava only
icon = "${projectDir}/src/main/mac-resources/Lilith.icns"
bundleExtras = [
'CFBundleShortVersionString': version,
//'CFBundleGetInfoString': copyright,
'NSHumanReadableCopyright': copyright,
'NSSupportsAutomaticGraphicsSwitching': true,
]
javaProperties = [
'apple.laf.useScreenMenuBar': 'true'
]
javaExtras = [
'-Xdock:name': appName // About name
]
}
createDmg {
enabled false
}
jar {
manifest.attributes(
'Main-Class': "${mainClassName}",
// Class-Path must be evaluated at runtime not configuration time.
// see http://gradle.1045684.n5.nabble.com/Manifest-classpath-incomplete-and-distribution-ZIP-empty-td2635807.html
'Class-Path': "${ -> configurations.runtime.collect { File file -> file.name }.sort().join(' ')}"
)
}
processResources {
def props = [
'lilithVersion': version,
'slf4jVersion': versions.slf4j,
'logbackVersion': versions.logback,
'gitRevision': project.gitHeadHash,
'timestamp': "${System.currentTimeMillis()}"
]
// props is manually added as input to circumvent the following issues:
// - Change in filtered resource not picked up by archive tasks
// http://issues.gradle.org/browse/GRADLE-1298
// - processResources task considered up-to-date although its spec has changed
// https://issues.gradle.org/browse/GRADLE-1276
// - Copy tasks do not consider filter/expansion properties in up-to-date checks
// https://issues.gradle.org/browse/GRADLE-1646
inputs.properties props
// See also:
// http://forums.gradle.org/gradle/topics/1_7_rc_1_probably_erroneous_including_duplicate_file_warnings
filesMatching '**/*.properties', { expand props }
filesMatching '**/*.xhtml', { expand props }
}
project.ext.distSpec = copySpec {
into("lilith-${version}") {
//println "projectDir: ${projectDir}"
from(projectDir) {
include 'COPYING'
include 'COPYING.LESSER'
include 'LICENSE-2.0.txt'
include 'build.txt'
}
from(projectDir) {
include 'readme.txt'
expand(
'lilithVersion': version,
'slf4jVersion': versions.slf4j,
'logbackVersion': versions.logback,
'log4jVersion': versions.log4j,
'commonsLoggingVersion': versions.commonsLogging,
)
}
into('bin') {
from("${projectDir}/src/bin") {
include 'lilith.bat'
}
}
into('bin') {
from("${projectDir}/src/bin") {
include 'lilith'
fileMode = 0755
filter(FixCrLfFilter,
eol: FixCrLfFilter.CrLf.newInstance('lf'),
tab: FixCrLfFilter.AddAsisRemove.newInstance('asis'),
eof: FixCrLfFilter.AddAsisRemove.newInstance('remove'),
fixlast: true)
}
}
into('lib') {
from configurations.default
from configurations.default.allArtifacts.files
exclude '*-sources.jar'
exclude '*-javadoc.jar'
rename 'de.huxhorn.lilith-(.*).jar', 'lilith.jar'
}
}
}
task myDistZip(dependsOn: configurations.default.allArtifacts.buildDependencies, type: Zip) {
description = 'Creates a ZIP containing the Lilith distribution.'
classifier = 'bin'
with distSpec
}
task myDistTgz(dependsOn: configurations.default.allArtifacts.buildDependencies, type: Tar) {
description = 'Creates a TGZ containing the Lilith distribution.'
classifier = 'bin'
compression = Compression.GZIP
with distSpec
}
task appTgz(dependsOn: createApp, type: Tar) {
description = 'Creates a TGZ containing the Lilith Mac OS X app.'
classifier = 'app'
compression = Compression.GZIP
from "${projectDir}/build/macApp"
}
signing {
required = { !version.endsWith("SNAPSHOT") }
sign shadowJar
sign myDistZip
sign myDistTgz
sign appTgz
}
}
// source: https://gist.github.com/aalmiray/e6f54aa4b3803be0bcac
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
dependsOn = subprojects.jacocoTestReport
dependsOn = subprojects.test
additionalSourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories = files(subprojects.sourceSets.main.output)
executionData = files(subprojects.jacocoTestReport.executionData)
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
onlyIf = {
true
}
doFirst {
executionData = files(executionData.findAll {
it.exists()
})
}
}
coveralls {
jacocoReportPath = 'build/reports/jacoco/jacocoRootReport/jacocoRootReport.xml'
sourceDirs += jacocoRootReport.sourceDirectories
}
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."
}
}