forked from AY2425S1-CS2103T-F11-4/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
163 lines (141 loc) · 5.98 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
plugins {
id 'java'
id 'checkstyle'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'application'
id 'jacoco'
}
mainClassName = 'seedu.address.Main'
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
checkstyle {
toolVersion = '10.2'
}
test {
jvmArgs += [
'--add-opens', 'javafx.graphics/com.sun.javafx.application=ALL-UNNAMED',
'--add-exports', 'javafx.graphics/com.sun.javafx.application=ALL-UNNAMED',
'--add-opens', 'javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED',
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
'--add-opens', 'java.base/java.util=ALL-UNNAMED'
]
useJUnitPlatform()
// Enhance logging for failed tests
testLogging {
events "failed"
exceptionFormat = "short"
showStandardStreams = true
}
doFirst {
exclude "**/**UiTest*"
}
reports {
html.required = true
}
doLast {
def reportFile = file("${buildDir}/reports/tests/test/index.html")
def osName = System.getProperty("os.name").toLowerCase()
if (osName.contains("win")) {
// For Windows
def path = reportFile.absolutePath
def driveLetter = path.charAt(0).toLowerCase()
def remainingPath = path.substring(2).replace('\\', '/')
println "\nTest report generated at: file:///${driveLetter}${remainingPath}"
} else {
// For macOS/Linux
println "\nTest report generated at: file://${reportFile.absolutePath}"
}
}
finalizedBy jacocoTestReport
}
tasks.register('uiTest', Test) {
jvmArgs += [
'--add-opens', 'javafx.graphics/com.sun.javafx.application=ALL-UNNAMED',
'--add-exports', 'javafx.graphics/com.sun.javafx.application=ALL-UNNAMED',
'--add-opens', 'javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED',
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
'--add-opens', 'java.base/java.util=ALL-UNNAMED'
]
doFirst {
include "**/**UiTest*"
}
useJUnitPlatform()
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test
def disallowedOS = ['ubuntu', 'nux']
def os = System.getProperty("os.name").toLowerCase()
def isAllowed = disallowedOS.every { !os.contains(it) }
if (isAllowed) {
dependsOn uiTest
}
sourceDirectories.from files(sourceSets.main.allSource.srcDirs)
classDirectories.from files(sourceSets.main.output)
executionData.from files(jacocoTestReport.executionData)
afterEvaluate {
classDirectories.from files(classDirectories.files.collect {
fileTree(dir: it, exclude: ['**/*.jar'])
})
}
executionData(fileTree(dir: "$buildDir/jacoco", includes: ["**/*.exec"]))
reports {
html.required = true
xml.required = true
}
doLast {
def reportFile = file("${buildDir}/reports/jacoco/test/html/index.html")
def osName = System.getProperty("os.name").toLowerCase()
if (osName.contains("win")) {
// For Windows
def path = reportFile.absolutePath
def driveLetter = path.charAt(0).toLowerCase()
def remainingPath = path.substring(2).replace('\\', '/')
println "\nTest coverage report generated at: file:///${driveLetter}${remainingPath}"
} else {
// For macOS/Linux
println "\nTest coverage report generated at: file://${reportFile.absolutePath}"
}
}
}
task coverage(type: JacocoReport) {
dependsOn jacocoTestReport
}
dependencies {
String jUnitVersion = '5.4.0'
String javaFxVersion = '17.0.7'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.0'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.7.4'
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.10.0'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: jUnitVersion
testImplementation "org.testfx:testfx-core:4.0.17"
testImplementation "org.testfx:testfx-junit5:4.0.17"
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.mockito:mockito-core:4.1.0'
testImplementation 'org.mockito:mockito-inline:4.1.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: jUnitVersion
}
shadowJar {
archiveFileName = 'EZSTATE.jar'
}
run {
enableAssertions = true
}
defaultTasks 'clean', 'test'