forked from se-edu/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 109
/
build.gradle
174 lines (144 loc) · 4.59 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
/*
* 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 {
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
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/" }
}
// 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'
junitVersion = '4.12'
testFxVersion = '4.0.+'
monocleVersion = '1.8.0_20'
checkstyleVersion = '7.1.2'
libDir = 'lib'
}
checkstyle {
toolVersion = "$checkstyleVersion"
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/jacocoHtml"
}
}
dependencies {
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"
testCompile "junit:junit:$junitVersion"
testCompile "org.testfx:testfx-core:$testFxVersion"
testCompile "org.testfx:testfx-junit:$testFxVersion"
testCompile "org.testfx:testfx-legacy:$testFxVersion", {
exclude group: "junit", module: "junit"
}
testCompile "org.testfx:openjfx-monocle:$monocleVersion"
}
sourceSets {
main {
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/main/resources'
}
}
}
shadowJar {
archiveName = "addressbook.jar"
manifest {
attributes "Main-Class": "seedu.address.MainApp"
}
destinationDir = file("${buildDir}/jar/")
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
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' }
}
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 nonGuiTests(type: AddressBookTest) {
include 'seedu/address/**'
jacoco {
destinationFile = new File("${buildDir}/jacoco/test.exec")
}
}
// Test mode depends on whether headless task has been run
task allTests(type: AddressBookTest) {
jacoco {
destinationFile = new File("${buildDir}/jacoco/test.exec")
}
}
task headless << {
println "Setting headless mode properties."
guiTests.setHeadless()
nonGuiTests.setHeadless()
allTests.setHeadless()
}
// Makes sure that headless properties are set before running tests
nonGuiTests.mustRunAfter headless
guiTests.mustRunAfter headless
allTests.mustRunAfter headless
defaultTasks 'clean', 'headless', 'allTests', 'coverage'