forked from JabRef/jabref
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
530 lines (440 loc) · 17.1 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
import groovy.json.JsonSlurper
import org.gradle.internal.os.OperatingSystem
// to update the gradle wrapper, execute
// ./gradlew wrapper --gradle-version=4.4.1 --distribution-type=bin
buildscript {
repositories {
mavenLocal()
jcenter()
maven {
url 'https://oss.sonatype.org/content/groups/public'
}
}
}
plugins {
id 'com.gradle.build-scan' version '1.16'
id 'com.install4j.gradle' version '7.0.9'
id 'com.github.johnrengelman.shadow' version '4.0.2'
id "com.simonharrer.modernizer" version '1.6.0-1'
id 'me.champeau.gradle.jmh' version '0.4.8'
id 'net.ltgt.errorprone' version '0.6.1'
id 'com.github.ben-manes.versions' version '0.20.0'
}
// use the gradle build scan feature: https://scans.gradle.com/get-started
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'project-report'
apply plugin: 'jacoco'
apply plugin: 'install4j'
apply plugin: 'me.champeau.gradle.jmh'
apply plugin: 'checkstyle'
apply from: 'eclipse.gradle'
apply from: 'localization.gradle'
apply from: 'xjc.gradle'
group = "org.jabref"
version = "5.0-dev"
project.ext.threeDotVersion = "5.0.0.0"
project.ext.install4jDir = hasProperty("install4jDir") ? getProperty("install4jDir") : (OperatingSystem.current().isWindows() ? 'C:/Program Files/install4j7' : 'install4j7')
sourceCompatibility = 1.8
targetCompatibility = 1.8
mainClassName = "org.jabref.JabRefMain"
// These are the Java version requirements we will check on each start of JabRef
ext.minRequiredJavaVersion = "1.8.0_171"
ext.allowJava9 = false
sourceSets {
main {
java {
srcDirs = ["src/main/java", "src/main/gen"]
}
resources {
srcDirs = ["src/main/java", "src/main/resources"]
}
}
test {
java {
srcDirs = ["src/test/java"]
}
resources {
srcDirs = ["src/test/resources"]
}
}
}
repositories {
mavenLocal()
jcenter()
maven {
url 'https://oss.sonatype.org/content/groups/public'
}
}
configurations {
antlr3
antlr4
errorprone
}
dependencies {
// Include all jar-files in the 'lib' folder as dependencies
compile fileTree(dir: 'lib', includes: ['*.jar'])
compile 'com.jgoodies:jgoodies-common:1.8.1'
compile 'com.jgoodies:jgoodies-forms:1.9.0'
compile 'org.apache.pdfbox:pdfbox:2.0.13'
compile 'org.apache.pdfbox:fontbox:2.0.13'
compile 'org.apache.pdfbox:xmpbox:2.0.13'
compile group: 'org.apache.tika', name: 'tika-core', version: '1.20'
// required for reading write-protected PDFs - see https://github.com/JabRef/jabref/pull/942#issuecomment-209252635
compile 'org.bouncycastle:bcprov-jdk15on:1.61'
compile 'commons-cli:commons-cli:1.4'
compile "org.libreoffice:juh:5.4.2"
compile "org.libreoffice:jurt:5.4.2"
compile "org.libreoffice:ridl:5.4.2"
compile "org.libreoffice:unoil:5.4.2"
compile 'io.github.java-diff-utils:java-diff-utils:4.0'
compile 'info.debatty:java-string-similarity:1.1.0'
antlr3 'org.antlr:antlr:3.5.2'
compile 'org.antlr:antlr-runtime:3.5.2'
antlr4 'org.antlr:antlr4:4.7.2'
compile 'org.antlr:antlr4-runtime:4.7.2'
compile 'mysql:mysql-connector-java:8.0.15'
compile 'org.postgresql:postgresql:42.2.5'
compile 'net.java.dev.glazedlists:glazedlists_java15:1.9.1'
compile 'com.google.guava:guava:27.0.1-jre'
// JavaFX stuff
compile 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-4'
compile 'de.saxsys:mvvmfx-validation:1.7.0'
compile 'de.saxsys:mvvmfx:1.7.0'
compile 'org.fxmisc.easybind:easybind:1.0.3'
compile 'org.fxmisc.flowless:flowless:0.6.1'
compile 'org.fxmisc.richtext:richtextfx:0.9.2'
compile 'com.sibvisions.external.jvxfx:dndtabpane:0.1'
compile 'javax.inject:javax.inject:1'
compile 'com.jfoenix:jfoenix:8.0.8'
// Cannot be updated to 9.*.* until Jabref works with Java 9
compile 'org.controlsfx:controlsfx:8.40.15-SNAPSHOT'
compile 'org.jsoup:jsoup:1.11.3'
compile 'com.mashape.unirest:unirest-java:1.4.9'
// >1.8.0-beta is required for java 9 compatibility
compile 'org.slf4j:slf4j-api:1.8.0-beta2'
compile 'org.apache.logging.log4j:log4j-slf4j18-impl:2.11.2'
compile 'org.apache.logging.log4j:log4j-jcl:2.11.2'
compile 'org.apache.logging.log4j:log4j-api:2.11.2'
compile 'org.apache.logging.log4j:log4j-core:2.11.2'
compile 'de.undercouch:citeproc-java:1.0.1'
compile 'com.github.tomtung:latex2unicode_2.12:0.2.2'
errorproneJavac 'com.google.errorprone:javac:1.8.0-u20'
compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.3.1'
compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.3.1'
testImplementation 'org.junit.jupiter:junit-jupiter:5.4.0'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.4.0'
testCompile 'org.junit.platform:junit-platform-launcher:1.4.0'
testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1'
testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.2'
testCompile 'org.mockito:mockito-core:2.24.0'
testCompile 'com.github.tomakehurst:wiremock:2.21.0'
testCompile 'org.assertj:assertj-swing-junit:3.9.2'
testCompile 'org.reflections:reflections:0.9.11'
testCompile 'org.xmlunit:xmlunit-core:2.6.2'
testCompile 'org.xmlunit:xmlunit-matchers:2.6.2'
testRuntime 'com.tngtech.archunit:archunit-junit5-engine:0.9.3'
testCompile 'com.tngtech.archunit:archunit-junit5-api:0.9.3'
testCompile "org.testfx:testfx-core:4.0.+"
testCompile "org.testfx:testfx-junit5:4.0.+"
checkstyle 'com.puppycrawl.tools:checkstyle:8.17'
}
jacoco {
toolVersion = '0.8.1'
}
dependencyUpdates {
outputFormatter = "json"
}
// We have some dependencies which cannot be updated due to various reasons.
dependencyUpdates.resolutionStrategy = {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
if (selection.candidate.version ==~ /[0-9].*SNAPSHOT/) {
selection.reject("Ignore SNAPSHOT releases")
}
}
rules.withModule("com.gradle.build-scan:com.gradle.build-scan.gradle.plugin") { ComponentSelection selection ->
if (selection.candidate.version ==~ /2.*/) {
selection.reject("Cannot be upgraded to version 2 until we upgrade to gradle 5")
}
}
rules.withModule("org.controlsfx:controlsfx") { ComponentSelection selection ->
if (selection.candidate.version ==~ /9.*/) { // Reject version 9 or higher
selection.reject("Cannot be updated to 9.*.* until Jabref works with Java 9")
}
}
rules.withModule("com.github.tomtung:latex2unicode_2.12") { ComponentSelection selection ->
if (selection.candidate.version ==~ /0.2.[3,4]/) {
// Reject version higher than 2.0.2. see https://github.com/JabRef/jabref/pull/3781
selection.reject("Cannot be updated to 0.2.4 until JabRef is prepared for it")
}
}
rules.withModule("com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin") { ComponentSelection selection ->
if (selection.candidate.version ==~ /4.*/) {
selection.reject("Version 4.X breaks the release process.")
}
}
rules.withModule("de.jensd:fontawesomefx-materialdesignfont") { ComponentSelection selection ->
if (selection.candidate.version ==~ /2.*/) {
selection.reject("Cannot be upgraded to version 2")
}
}
rules.withModule("com.jfoenix:jfoenix") { ComponentSelection selection ->
if (selection.candidate.version ==~ /9.*/) { // Reject version 9 or higher
selection.reject("Cannot be updated to 9.*.* until Jabref works with Java 9")
}
}
rules.withModule("com.google.errorprone:javac") { ComponentSelection selection ->
if (selection.candidate.version ==~ /1.9.*/ || selection.candidate.version ==~ /9.*/) {
selection.reject("Cannot be updated to 9.*.* until Jabref works with Java 9")
}
}
rules.withModule("com.sun.xml.bind:jaxb-xjc") { ComponentSelection selection ->
if (!(selection.candidate.version ==~ /2.2.4.*/) || selection.candidate.version ==~ /2.[3-9].*/) {
selection.reject("Cannot be updated to 2.2.5 or higher.")
}
}
}
}
task checkOutdatedDependencies(dependsOn: dependencyUpdates) {
doLast {
def dependencyReport = new JsonSlurper().parseText(new File("build/dependencyUpdates/report.json").text)
assert dependencyReport.outdated.count == 0: "There are outdated dependencies in build.gradle!\n Run ./gradlew dependencyUpdates to see which"
}
}
clean {
delete "src/main/gen"
}
processResources {
filteringCharset = 'UTF-8'
filesMatching("build.properties") {
expand(version: project.version,
"year": String.valueOf(Calendar.getInstance().get(Calendar.YEAR)),
"authors": new File('AUTHORS').readLines().findAll { !it.startsWith("#") }.join(", "),
"developers": new File('DEVELOPERS').readLines().findAll { !it.startsWith("#") }.join(", "),
"azureInstrumentationKey": System.getenv('AzureInstrumentationKey'),
"minRequiredJavaVersion": minRequiredJavaVersion,
"allowJava9": allowJava9
)
filteringCharset = 'UTF-8'
}
filesMatching("resource/**/meta.xml") {
expand version: project.version
}
}
task generateSource(dependsOn: ["generateBstGrammarSource", "generateSearchGrammarSource"]) {
group = 'JabRef'
description 'Generates all Java source files.'
}
task generateBstGrammarSource(type: JavaExec) {
group 'JabRef'
description 'Generates BstLexer.java and BstParser.java from the Bst.g grammar file using antlr3.'
File antlrSource = file('src/main/antlr3/org/jabref/bst/Bst.g')
inputs.file antlrSource
outputs.file file('src/main/gen/org/jabref/logic/bst/BstLexer.java')
outputs.file file('src/main/gen/org/jabref/logic/bst/BstParser.java')
main = 'org.antlr.Tool'
classpath = configurations.antlr3
args = ["-o", file('src/main/gen/org/jabref/logic/bst/'), antlrSource]
}
task generateSearchGrammarSource(type: JavaExec) {
String grammarFile = "Search"
group 'JabRef'
description "Generates java files for ${grammarFile}.g antlr4."
String packagePath = "org/jabref/search"
File antlrPath = file("src/main/antlr4")
File genPath = file("src/main/gen")
File antlrSource = file("$antlrPath/$packagePath/${grammarFile}.g4")
File destinationDir = file("$genPath/$packagePath")
inputs.file antlrSource
outputs.file file("$destinationDir/${grammarFile}Parser.java")
outputs.file file("$destinationDir/${grammarFile}Lexer.java")
outputs.file file("$destinationDir/${grammarFile}Visitor.java")
outputs.file file("$destinationDir/${grammarFile}BaseVisitor.java")
outputs.file file("$destinationDir/${grammarFile}.tokens")
outputs.file file("$destinationDir/${grammarFile}Lexer.tokens")
main = 'org.antlr.v4.Tool'
classpath = configurations.antlr4
args = ["-o", destinationDir, "-visitor", "-no-listener", "-package", "org.jabref.search", antlrSource]
}
compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:none"
}
compileJava.dependsOn "generateSource"
compileTestJava {
options.encoding = 'UTF-8'
}
javadoc {
options {
encoding = 'UTF-8'
version = true
author = true
}
}
// Test tasks
test {
useJUnitPlatform {
excludeTags 'DatabaseTest', 'FetcherTest', 'GUITest', 'org.jabref.testutils.category.FetcherTest', 'org.jabref.testutils.category.GUITest'
}
testLogging {
// set options for log level LIFECYCLE
events "failed"
exceptionFormat "full"
}
}
task databaseTest(type: Test) {
useJUnit {
includeCategories 'org.jabref.testutils.category.DatabaseTest'
}
}
task fetcherTest(type: Test) {
useJUnit {
includeCategories 'org.jabref.testutils.category.FetcherTest'
}
}
task guiTest(type: Test) {
useJUnit {
includeCategories 'org.jabref.testutils.category.GUITest'
}
}
// Test result tasks
task copyTestResources(type: Copy) {
from "${projectDir}/src/test/resources"
into "${buildDir}/classes/test"
}
processTestResources.dependsOn copyTestResources
tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
jacoco {
append = true
}
}
task jacocoMerge(type: JacocoMerge) {
executionData file("$buildDir/jacoco/test.exec"), file("$buildDir/jacoco/databaseTest.exec"), file("$buildDir/jacoco/fetcherTest.exec")
dependsOn test, databaseTest, fetcherTest
}
jacocoTestReport {
executionData jacocoMerge.destinationFile
dependsOn jacocoMerge
reports {
xml.enabled = true // coveralls plugin depends on xml format report
html.enabled = true
}
}
// Code quality tasks
checkstyle {
}
modernizer {
// We have more than 20 issues, which are not fixed yet. Nevertheless, we produce the modernizer output.
// See https://github.com/andrewgaul/modernizer-maven-plugin for more information on modernizer
failOnViolations = false
}
// Release tasks
shadowJar {
transform(com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer)
classifier 'fat'
}
/*
* Changes project.version to VERSION--snapshot--DATE--GIT_HASH
*/
if (hasProperty('dev')) {
String command = "git log --pretty=format:%cd--%h -n 1 --date=short"
String commitInfo = ""
if (OperatingSystem.current().isWindows()) {
commitInfo = "cmd /c $command".execute().in.text
} else {
commitInfo = command.execute().in.text
}
// determine branch
command = "git symbolic-ref -q --short HEAD"
String branchName = ""
if (OperatingSystem.current().isWindows()) {
branchName = "cmd /c $command".execute().in.text
} else {
branchName = command.execute().in.text
}
// A newline is returned. Remove it. (trim())
// In the context of github, the branch name could be something like "pull/277"
// "/" is an illegal character. To be safe, all illegal filename characters are replaced by "_"
// http://stackoverflow.com/a/15075907/873282 describes the used pattern.
branchName = branchName.trim().replaceAll("[^a-zA-Z0-9.-]", "_")
// hack string
// first the date (%cd), then the branch name, and finally the commit id (%h)
String infoString = commitInfo.substring(0, 10) + "--" + branchName + "--" + commitInfo.substring(12)
project.version += "--snapshot--" + infoString
}
install4j {
installDir = file(project.ext.install4jDir)
}
task generateFinalJabRefPS1File(type: Copy) {
from('buildres') {
include 'JabRef.ps1'
}
into 'build'
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [jabRefJarFileName: jar.archiveName])
}
// has to be defined AFTER 'dev' things to have the correct project.version
task media(type: com.install4j.gradle.Install4jTask, dependsOn: ["releaseJar", "generateFinalJabRefPS1File"]) {
projectFile = file('jabref.install4j')
release = project.version
winKeystorePassword = System.getenv('CERTIFICATE_PW')
macKeystorePassword = System.getenv('CERTIFICATE_PW')
variables = [
versionFourDots: project.ext.threeDotVersion,
buildFileName : jar.archiveName,
version : project.version
]
doLast {
copy {
from "build/install4j"
into "build/releases"
}
}
}
task release(dependsOn: ["media", "releaseJar"]) {
group = 'JabRef - Release'
description 'Creates a release for all target platforms.'
}
task releaseJar(dependsOn: "shadowJar") {
group = 'JabRef - Release'
description "Creates a Jar release."
doLast {
copy {
from("$buildDir/libs/JabRef-${project.version}-fat.jar")
into("$buildDir/releases")
rename { String fileName ->
fileName.replace('-fat', '')
}
}
// set executable with read permissions (first true) and for all (false)
file("$buildDir/releases/JabRef-${project.version}.jar").setExecutable(true, false)
}
}
task snapJar(dependsOn: "releaseJar", type: Delete) {
delete fileTree(dir: "$buildDir/releases/", exclude: "JabRef-${project.version}.jar")
}
jmh {
warmupIterations = 5
iterations = 10
fork = 2
}
// Source: https://stackoverflow.com/a/44168582/873282
task downloadDependencies {
description "Pre-downloads *most* dependencies"
doLast {
configurations.getAsMap().each { name, config ->
println "Retrieving dependencies for $name"
try {
config.files
} catch (e) {
// some cannot be resolved, just log them
project.logger.info e.message
}
}
}
}