-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
457 lines (396 loc) · 15.8 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
/*
* Gradle Configuration File
*
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at http://gradle.org/docs/2.2.1/userguide/tutorial_java_projects.html
*/
plugins {
id "com.github.kt3k.coveralls" version "2.4.0"
id 'com.github.johnrengelman.shadow' version '1.2.3'
}
allprojects {
version = 'V1.6.1ea'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'checkstyle'
checkstyle {
toolVersion = '6.19'
sourceSets = [project.sourceSets.main]
}
apply plugin: 'pmd'
apply plugin: 'findbugs'
findbugs {
excludeFilter = file("${projectDir}/config/findbugs/excludeFilter.xml")
}
apply plugin: 'jacoco'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
repositories {
jcenter()
mavenCentral()
maven { url "https://repo.eclipse.org/content/repositories/egit-releases/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "http://maven.teamdev.com/repository/products" }
}
// This part is similar to global variables
// Access them by using double-quoted strings (GStrings) and referencing by $ e.g. "Variable contains $Variable"
project.ext {
controlsFxVersion = '8.40.11'
guavaVersion = '19.0'
jacksonVersion = '2.7.0'
jacksonDataTypeVersion = '2.7.4'
jKeyMasterVersion = '1.2'
jxBrowserVersion = '6.4'
junitVersion = '4.12'
log4jVersion = '2.6'
mockitoVersion = '1+'
mockServerVersion = '3.10.1'
powermockVersion = '1.6.5'
testFxVersion = '3.1.0'
monocleVersion = '1.8.0_20'
slf4jSimpleVersion = '1.6.4'
commonsIoVersion = '2.4'
// Commons and Updater versions to be updated here on release
commonsArchiveName = 'commons-0.0.2.jar'
updaterArchiveName = "updater.jar"
mainAppArchiveName = 'resource-' + project.version + '.jar'
mainAppMainClass = 'address.MainApp'
installerArchiveName = 'installer-' + project.version + '.jar'
installerMainClass = 'installer.Installer'
launcherArchiveName = 'addressbook-' + project.version + '.jar'
launcherMainClass = 'launcher.Launcher'
licenceArchiveName = 'licence.jar'
generateVersionDataMainClass = 'address.util.VersionDataGenerator'
libDir = 'lib'
updaterDestDir = 'src/main/resources/updater'
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/jacocoHtml"
}
}
sourceSets {
main {
java {
srcDir 'src/main/java'
include('address/**/*')
include('hubturbo/**/*')
include('commons/**/*')
}
resources {
srcDir 'src/main/resources'
}
}
updater {
java {
srcDir 'src/main/java'
include('updater/**/*')
exclude('updater/VersionDataGenerator.java')
include('commons/**/*')
}
resources {
srcDir 'src/main/resources'
}
}
commons {
java {
srcDir 'src/main/java'
include('commons/**/*')
}
}
installer {
java {
srcDir 'src/main/java/'
include('installer/**/*')
include('commons/**/*')
}
resources {
srcDir "."
include("$libDir/*")
exclude("$libDir/jxbrowser-*-*.jar") // platform-specific jxbrowser
include("$launcherArchiveName")
include('VersionData.json')
}
}
launcher {
java {
srcDir 'src/main/java'
include('launcher/**/*')
}
}
generateVersionData {
java {
srcDir 'src/main/java/'
}
}
}
dependencies {
compile "org.apache.logging.log4j:log4j-api:$log4jVersion"
compile "org.apache.logging.log4j:log4j-core:$log4jVersion"
compile "org.slf4j:slf4j-simple:$slf4jSimpleVersion" // Required to suppress warning, for jkeymaster, see http://www.slf4j.org/codes.html#StaticLoggerBinder
compile "commons-io:commons-io:$commonsIoVersion"
compile "org.controlsfx:controlsfx:$controlsFxVersion"
compile "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonDataTypeVersion"
compile "com.google.guava:guava:$guavaVersion"
compile "com.teamdev.jxbrowser:jxbrowser-win:$jxBrowserVersion"
compile "com.teamdev.jxbrowser:jxbrowser-mac:$jxBrowserVersion"
compile "com.teamdev.jxbrowser:jxbrowser-linux32:$jxBrowserVersion"
compile "com.teamdev.jxbrowser:jxbrowser-linux64:$jxBrowserVersion"
compile "org.controlsfx:controlsfx:$controlsFxVersion"
compile "com.github.tulskiy:jkeymaster:$jKeyMasterVersion"
compile files("$libDir/$licenceArchiveName")
compile files("$libDir/$commonsArchiveName")
testCompile "junit:junit:$junitVersion"
testCompile "org.testfx:testfx-core:4.0.+"
testCompile "org.testfx:testfx-junit:4.0.+"
testCompile "org.testfx:testfx-legacy:4.0.+", {
exclude group: "junit", module: "junit"
}
testCompile "org.mockito:mockito-core:$mockitoVersion"
testCompile "org.powermock:powermock-api-mockito:$powermockVersion"
testCompile "org.powermock:powermock-module-junit4:$powermockVersion"
testCompile "org.testfx:openjfx-monocle:$monocleVersion"
installerCompile "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
installerCompile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonDataTypeVersion"
installerCompile "org.apache.logging.log4j:log4j-api:$log4jVersion"
installerCompile "org.apache.logging.log4j:log4j-core:$log4jVersion"
updaterCompile "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
updaterCompile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonDataTypeVersion"
updaterCompile "org.apache.logging.log4j:log4j-api:$log4jVersion"
updaterCompile "org.apache.logging.log4j:log4j-core:$log4jVersion"
updaterCompile files("$libDir/$commonsArchiveName")
commonsCompile "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
commonsCompile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonDataTypeVersion"
commonsCompile "org.apache.logging.log4j:log4j-api:$log4jVersion"
commonsCompile "org.apache.logging.log4j:log4j-core:$log4jVersion"
}
configurations {
generateVersionDataCompile {
extendsFrom compile
}
}
// Remove any old custom dependencies
task deleteOldCustomDependenciesFromLibrary(type: Delete) {
delete fileTree(dir: ".", include: 'addressbook-V*.*.*.jar')
delete fileTree(dir: "$libDir", includes: ['commons-*.*.*.jar', 'resource-V*.*.*.jar'])
}
// Copy downloaded dependencies from Gradle's cache into the library directory
task copyAllDependenciesToLibrary(type: Copy) {
from(configurations.compile) {
exclude("$licenceArchiveName")
}
into "$libDir/"
}
copyAllDependenciesToLibrary.dependsOn deleteOldCustomDependenciesFromLibrary
copyAllDependenciesToLibrary.dependsOn clean
// Commons jar
task createCommonsJar(type: Jar) {
archiveName = "$commonsArchiveName"
from sourceSets.commons.output
destinationDir = file("$libDir/")
}
createCommonsJar.dependsOn copyAllDependenciesToLibrary
compileCommonsJava.mustRunAfter copyAllDependenciesToLibrary
// Updater jar
task createUpdaterJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
archiveName = "$updaterArchiveName"
from sourceSets.updater.output
configurations = [project.configurations.updaterCompile]
destinationDir = file("$updaterDestDir/")
}
createUpdaterJar.dependsOn createCommonsJar
// Main application jar
jar {
archiveName = "$mainAppArchiveName"
manifest {
attributes "Class-Path": configurations.runtime.files.collect { "$libDir/${it.name}" }.join(" ") // required for DependencyChecker
}
from sourceSets.main.output
from(rootDir) {
include "VersionData.json"
}
from(tasks.createUpdaterJar.destinationDir) {
include "$updaterArchiveName"
}
destinationDir = file("$libDir/")
}
jar.dependsOn createUpdaterJar
compileJava.mustRunAfter createUpdaterJar // jar adds compileJava, but it runs at the beginning (which fails without update.jar)
// delay this until update.jar is created
// Creates the launcher, which launches the main application with custom arguments
task createLauncherJar(type: Jar) {
archiveName = "$launcherArchiveName"
manifest {
attributes "Main-Class": "$launcherMainClass",
"Class-Path": configurations.compile.files.collect { "$libDir/${it.name}" }.join(" ")
}
from sourceSets.launcher.output
destinationDir = file(".")
}
createLauncherJar.dependsOn jar
// Creates the installer, which will pack necessary classes for installation and all dependencies found in lib/
task createInstallerJar(type: Jar) {
archiveName = "$installerArchiveName"
manifest {
attributes "Main-Class": "$installerMainClass",
"Class-Path": configurations.installerRuntime.files.collect { "$libDir/${it.name}" }.join(" ")
}
from sourceSets.installer.output
}
createInstallerJar.dependsOn createLauncherJar
compileInstallerJava.mustRunAfter createLauncherJar // Compile installer only after its dependencies & resources are done
task generateVersionData(type: JavaExec) {
main = "$generateVersionDataMainClass"
def arguments = "$mainAppArchiveName " + "$launcherArchiveName " + configurations.runtime.files.collect { "$it.name" }.join(" ")
classpath = sourceSets.generateVersionData.runtimeClasspath
args arguments.split()
}
jacoco {
toolVersion = "0.7.5.201505241946"
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
task coverage(type: JacocoReport) {
sourceDirectories = files(allprojects.sourceSets.main.allSource.srcDirs)
classDirectories = files(allprojects.sourceSets.main.output)
executionData = files(allprojects.jacocoTestReport.executionData)
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it, exclude: ['**/*.jar'])
})
}
reports {
html.enabled = true
xml.enabled = true
}
}
coveralls {
sourceDirs = allprojects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${buildDir}/reports/jacoco/coverage/coverage.xml"
}
tasks.coveralls {
dependsOn coverage
onlyIf { System.env.'CI' }
}
task checkStyle { // A dummy task to run a set of tasks
}
class AddressBookTest extends Test {
public AddressBookTest() {
forkEvery = 1
systemProperty 'testfx.setup.timeout', '60000'
}
public void setHeadless() {
systemProperty 'java.awt.robot', 'true'
systemProperty 'testfx.robot', 'glass'
systemProperty 'testfx.headless', 'true'
systemProperty 'prism.order', 'sw'
systemProperty 'prism.text', 't2k'
}
}
task guiTests(type: AddressBookTest) {
include 'guitests/**'
jacoco {
destinationFile = new File("${buildDir}/jacoco/test.exec")
}
}
task guiUnitTests(type: AddressBookTest) {
include 'guiunittests/**'
jacoco {
destinationFile = new File("${buildDir}/jacoco/test.exec")
}
}
task unitTests(type: AddressBookTest) {
include 'address/**'
include 'commons/**'
jacoco {
destinationFile = new File("${buildDir}/jacoco/test.exec")
}
}
// Task to run specified test classes in headful mode
task headfulTests(type: AddressBookTest) {
// Have to separate by test classes instead of test methods since we cannot define methods to be excluded using TestFilter (for allTests)
// See https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/TestFilter.html for the list of its functionalities
// include 'guitests/FullSystemTest.class'
jacoco {
destinationFile = new File("${buildDir}/jacoco/test.exec")
}
}
headfulTests.onlyIf {
headfulTests.includes.size() > 0
}
// Task to run specified test classes in headless mode
task headlessTests(type: AddressBookTest) {
// include ''
jacoco {
destinationFile = new File("${buildDir}/jacoco/test.exec")
}
}
headlessTests.onlyIf {
headlessTests.includes.size() > 0
}
headlessTests.setHeadless()
// Task to run all tests asides from those specified in headfulTests and headlessTests
// Test mode depends on whether headless task has been run
task allTests(type: AddressBookTest) {
exclude headfulTests.includes
exclude headlessTests.includes
jacoco {
destinationFile = new File("${buildDir}/jacoco/test.exec")
}
}
task headless << {
println "Setting headless mode properties."
guiTests.setHeadless()
guiUnitTests.setHeadless()
unitTests.setHeadless()
allTests.setHeadless()
}
task headlessForMac << {
println "Setting headless mode properties."
guiTests.setHeadless()
guiUnitTests.setHeadless()
unitTests.setHeadless()
allTests.setHeadless()
String osName = System.getProperty("os.name");
if (osName.contains("Mac OS")) {
println "Mac OS detected, removing disruptive headless tests"
List<String> disruptiveHeadlessUnitTestsOnMac = new ArrayList<String>()
disruptiveHeadlessUnitTestsOnMac.add('address/keybindings/BindingsTest.class')
disruptiveHeadlessUnitTestsOnMac.add('address/keybindings/GlobalHotkeyProviderTest.class')
disruptiveHeadlessUnitTestsOnMac.add('address/keybindings/GlobalHotkeyTest.class')
disruptiveHeadlessUnitTestsOnMac.add('address/keybindings/KeyBindingsManagerApiTest.class')
disruptiveHeadlessUnitTestsOnMac.add('address/keybindings/KeyBindingsManagerTest.class')
List<String> disruptiveHeadlessGuiUnitTestsOnMac = new ArrayList<String>()
List<String> disruptiveHeadlessGuiTestsOnMac = new ArrayList<String>()
unitTests.excludes.addAll(disruptiveHeadlessUnitTestsOnMac)
guiUnitTests.excludes.addAll(disruptiveHeadlessGuiUnitTestsOnMac)
guiTests.excludes.addAll(disruptiveHeadlessGuiTestsOnMac)
allTests.excludes.addAll(disruptiveHeadlessUnitTestsOnMac)
allTests.excludes.addAll(disruptiveHeadlessGuiUnitTestsOnMac)
allTests.excludes.addAll(disruptiveHeadlessGuiTestsOnMac)
}
}
// Makes sure that headless properties are set before running tests
unitTests.mustRunAfter headless
guiUnitTests.mustRunAfter headless
guiTests.mustRunAfter headless
allTests.mustRunAfter headless
headless.shouldRunAfter checkStyle
unitTests.shouldRunAfter checkStyle
guiUnitTests.shouldRunAfter checkStyle
guiTests.shouldRunAfter checkStyle
allTests.shouldRunAfter checkStyle
checkStyle.shouldRunAfter clean
checkStyle.dependsOn checkstyleMain, checkstyleTest, findbugsMain, findbugsTest, pmdMain, pmdTest
defaultTasks 'clean', 'headless', 'allTests', 'coverage'