forked from JabRef/jabref
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
337 lines (273 loc) · 9.49 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
import org.gradle.internal.os.OperatingSystem
plugins {
id "eu.appsatori.fatjar" version "0.3"
id "edu.sc.seis.launch4j" version "1.1.4"
id "com.github.kt3k.coveralls" version "2.4.0"
id "edu.sc.seis.macAppBundle" version "2.1.1"
id "com.github.youribonnaffe.gradle.format" version "1.2"
}
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "application"
apply plugin: "project-report"
apply plugin: "sonar-runner"
apply plugin: "maven"
apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'
group = "net.sf.jabref"
version = "2.80dev"
project.ext.threeDotVersion = "2.80.0.0"
project.ext.nsisExec = hasProperty("nsisExec") ? getProperty("nsisExec") : "C:/Program Files/NSIS/makensis.exe"
sourceCompatibility = 1.8
targetCompatibility = 1.8
mainClassName = "net.sf.jabref.JabRefMain"
task wrapper(type: Wrapper) {
gradleVersion = '2.6'
}
repositories {
jcenter()
}
configurations {
antlr3
antlr4
}
dependencies {
compile 'com.jgoodies:jgoodies-common:1.8.1'
compile 'com.jgoodies:jgoodies-forms:1.9.0'
compile 'com.jgoodies:jgoodies-looks:2.7.0'
compile 'org.swinglabs.swingx:swingx-core:1.6.5-1'
compile 'org.apache.pdfbox:pdfbox:1.8.10'
compile 'org.apache.pdfbox:fontbox:1.8.10'
compile 'org.apache.pdfbox:jempbox:1.8.10'
compile 'commons-cli:commons-cli:1.3.1'
compile 'org.openoffice:juh:3.2.1'
compile 'org.openoffice:jurt:3.2.1'
compile 'org.openoffice:ridl:3.2.1'
compile 'org.openoffice:unoil:3.2.1'
antlr3 'org.antlr:antlr:3.5.2'
compile 'org.antlr:antlr-runtime:3.5.2'
antlr4 'org.antlr:antlr4:4.5.1-1'
compile 'org.antlr:antlr4-runtime:4.5.1-1'
compile 'mysql:mysql-connector-java:5.1.36'
compile 'org.postgresql:postgresql:9.4-1201-jdbc41'
compile 'net.java.dev.glazedlists:glazedlists_java15:1.9.1'
compile fileTree(dir: 'lib', includes: ['*.jar'])
compile 'net.java.dev.jna:jna:4.1.0'
compile 'com.google.guava:guava:18.0'
compile 'commons-logging:commons-logging:1.2'
compile 'junit:junit:4.12'
}
sourceSets {
main {
java {
srcDirs = ["src/main/java", "src/main/gen"]
}
}
}
processResources {
filesMatching("help/**/About.html") {
expand ("version": project.version,
"year": String.valueOf(Calendar.getInstance().get(Calendar.YEAR)),
"authors": new File('AUTHORS').readLines().findAll {!it.startsWith("#")}.join(", "))
}
filesMatching("resource/build.properties") {
expand version: project.version
}
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/net/sf/jabref/bst/Bst.g')
inputs.file antlrSource
outputs.file file('src/main/gen/net/sf/jabref/bst/BstLexer.java')
outputs.file file('src/main/gen/net/sf/jabref/bst/BstParser.java')
main = 'org.antlr.Tool'
classpath = configurations.antlr3
args = ["-o", file('src/main/gen/net/sf/jabref/bst/'), antlrSource]
}
task generateSearchGrammarSource(type: JavaExec) {
String grammarFile = "Search"
group 'JabRef'
description "Generates java files for ${grammarFile}.g antlr4."
String packagePath = "net/sf/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", "net.sf.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 {
testLogging {
exceptionFormat "full" // default is "short"
}
}
jacocoTestReport {
reports {
xml.enabled = true // coveralls plugin depends on xml format report
html.enabled = true
}
}
// enables `gradlew format`. Currently `LabelPatternUtil.java` is destroyed. Use with care!
format {
configurationFile = file('ide-settings/formatter_settings.xml')
// default: reformat main and test
//files = sourceSets.main.java
}
fatJar {
classifier 'fat'
manifest {
attributes 'Main-Class': project.mainClassName
}
}
/*
* 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 result = ""
if (OperatingSystem.current().isWindows()) {
result = "cmd /c $command".execute().in.text
} else {
result = command.execute().in.text
}
// remove enclosing ' of result
project.version += "--snapshot--" + result.substring(1, result.length() - 1)
}
task release(dependsOn: ["releaseWindows", "releaseMac", "releaseJar", "releaseSourceZip", "releaseSourceTar"]) {
group = 'JabRef - Release'
description 'Creates a release for all target platforms.'
}
launch4j {
mainClassName = project.mainClassName
version = project.ext.threeDotVersion
textVersion = project.version
jar = "../libs/JabRef-${project.version}-fat.jar"
icon = "${projectDir}/src/main/resources/images/icons/JabRef.ico"
copyright = "JabRef developers"
initialHeapSize = 32
maxHeapSize = 512
}
createExe.dependsOn "fatJar"
task releaseJar(dependsOn: "fatJar") {
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', '')
}
}
}
}
task releaseWindows(dependsOn: "launch4j") {
group = 'JabRef - Release'
description "Creates a Windows release."
doLast {
copy {
from("$projectDir/LICENSE")
from("$projectDir/README.md")
from("$buildDir/launch4j/JabRef.exe")
into("$buildDir/nsis")
}
if (OperatingSystem.current().isWindows()) {
exec {
commandLine project.ext.nsisExec, "/DVERSION=${version}", "${projectDir}/buildres/nsis/setup.nsi"
}
} else {
exec {
commandLine project.ext.nsisExec, "-DVERSION=${version}", "${projectDir}/buildres/nsis/setup.nsi"
}
}
copy {
from("$buildDir/nsis/JabRefSetup.exe")
from("$buildDir/nsis/JabRef.exe")
into("$buildDir/releases")
}
}
}
if(!OperatingSystem.current().isMacOsX()) {
// disable this task as it requires a command line tool only available on Mac OS X
createDmg.enabled = false
}
task releaseMac(dependsOn: "createAppZip") {
group = 'JabRef - Release'
description "Creates an OSX release."
doLast {
copy {
from "$buildDir/distributions/JabRef-${project.version}.zip"
into "$buildDir/releases"
rename { String fileName ->
fileName.replace('.zip', '-OSX.zip')
}
}
}
}
macAppBundle {
mainClassName = project.mainClassName
icon = "src/main/resources/images/icons/JabRef-Logo.icns"
highResolutionCapable = true
def map = [
"CFBundleTypeName" : "BibTeX file",
"CFBundleTypeRole" : "Editor",
"CFBundleTypeIconFile" : "JabRef-Logo.icns",
"CFBundleTypeExtensions": ["bib"]
]
bundleExtras.put("CFBundleDocumentTypes", [map])
}
task releaseSourceZip(type: Exec) {
group = 'JabRef - Release'
description "Creates a zip archive of the source code."
if (OperatingSystem.current().isWindows()) {
commandLine 'cmd', '/c', "git -c core.autocrlf=false -c core.eol=lf archive HEAD --format=zip > ${buildDir}/releases/JabRef-${version}-src.zip"
} else {
commandLine "bash", "-c", "git -c core.autocrlf=false -c core.eol=lf archive HEAD --format=zip > ${buildDir}/releases/JabRef-${version}-src.zip"
}
doFirst {
mkdir("$buildDir/releases")
}
}
task releaseSourceTar(type: Exec) {
group = 'JabRef - Release'
description "Creates a tar archive of the source code."
if (OperatingSystem.current().isWindows()) {
commandLine 'cmd', '/c', "git -c core.autocrlf=false -c core.eol=lf archive HEAD > ${buildDir}/releases/JabRef-${version}-src.tar.gz"
} else {
commandLine "bash", "-c", "git -c core.autocrlf=false -c core.eol=lf archive HEAD > ${buildDir}/releases/JabRef-${version}-src.tar.gz"
}
doFirst {
mkdir("$buildDir/releases")
}
}