forked from se-edu/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 110
/
build.gradle
229 lines (192 loc) · 6.33 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
/*
* 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'
id 'org.asciidoctor.convert' version '1.5.3'
id 'application'
}
// Specifies the entry point of the application
mainClassName = 'seedu.address.MainApp'
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.7-alpha'
monocleVersion = '1.8.0_20'
checkstyleVersion = '8.1'
libDir = 'lib'
}
checkstyle {
toolVersion = "$checkstyleVersion"
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/jacocoHtml"
}
}
dependencies {
compile group: 'org.fxmisc.easybind', name: 'easybind', version: '1.0.3'
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"
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'
/*
* Prints the currently running test's name in the CI's build log,
* so that we can check if tests are being silently skipped or
* stalling the build.
*/
if (System.env.'CI') {
beforeTest { descriptor ->
logger.lifecycle('Running test: ' + descriptor)
}
}
}
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/**'
include 'systemtests/**'
include 'seedu/address/ui/**'
jacoco {
destinationFile = new File("${buildDir}/jacoco/test.exec")
}
}
task nonGuiTests(type: AddressBookTest) {
include 'seedu/address/**'
exclude 'seedu/address/ui/**'
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
asciidoctor {
backends 'html5'
sourceDir 'docs'
outputDir "${buildDir}/docs"
attributes linkcss: true,
stylesheet: 'gh-pages.css',
'source-highlighter': 'coderay',
icons: 'font',
experimental: true,
sectlinks: true,
idprefix: '', // for compatibility with GitHub preview
idseparator: '-'
}
/*
* Copies stylesheets into the directory containing generated HTML files as
* Asciidoctor does not copy linked CSS files to the output directory when rendering.
* This is needed for linked stylesheets and embedded stylesheets which import other files.
*/
task copyStylesheets(type: Copy) {
from "${asciidoctor.sourceDir}/stylesheets"
into "${asciidoctor.outputDir}/html5/stylesheets"
}
asciidoctor.dependsOn copyStylesheets
task deployOfflineDocs(type: Copy) {
into('src/main/resources/docs')
from ("${asciidoctor.outputDir}/html5") {
include 'stylesheets/*'
include 'images/*'
include 'UserGuide.html'
}
}
deployOfflineDocs.dependsOn asciidoctor
processResources.dependsOn deployOfflineDocs
defaultTasks 'clean', 'headless', 'allTests', 'coverage', 'asciidoctor'