Skip to content

Commit 781f171

Browse files
Test coverage (#4410)
1 parent 5f364ad commit 781f171

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

build.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
id 'eclipse'
55
id 'idea'
66
id 'maven-publish'
7+
id 'jacoco'
78
alias libs.plugins.modDevGradle
89
//alias libs.plugins.shadow
910
alias libs.plugins.spotless
@@ -98,3 +99,34 @@ tasks.withType(JavaCompile).configureEach {
9899
lombok {
99100
version = "1.18.38"
100101
}
102+
103+
jacoco {
104+
applyTo runGameTestServer
105+
}
106+
107+
jacocoTestReport {
108+
doFirst {
109+
try {
110+
runGameTestServer.exec()
111+
} catch (RuntimeException ignored) {}
112+
}
113+
doLast {
114+
println "Coverage report location:"
115+
println " - file://${layout.buildDirectory.dir('coverage').map(a -> a.file('index.html')).get()}"
116+
println " - file://${layout.buildDirectory.dir('coverage').map(a -> a.file('coverage.xml')).get()}"
117+
}
118+
executionData runGameTestServer
119+
sourceSets sourceSets.test
120+
reports {
121+
csv.required = false
122+
xml.required = true
123+
html.outputLocation = layout.buildDirectory.dir('coverage')
124+
xml.outputLocation = layout.buildDirectory.dir('coverage').map(a -> a.file('coverage.xml'))
125+
}
126+
afterEvaluate {
127+
classDirectories.setFrom(files(classDirectories.files.collect {
128+
fileTree(dir: it, exclude: '**/client/**')
129+
fileTree(dir: it, exclude: '**/mixins/**')
130+
}))
131+
}
132+
}

0 commit comments

Comments
 (0)