I am using
- build.gradle.kts
- Jacoco: id(“org.barfuin.gradle.jacocolog”) version “3.1.0”
- Optics from Arrow library
Arrow library generates __OpticsKt
files that don’t have coverage in Jacoco. How to ignore them in the build.gradle.kts?
Answer
You need to add tasks.jacocoTestReport {
block:
tasks.jacocoTestReport {
classDirectories.setFrom(
sourceSets.main.get().output.asFileTree.matching {
exclude("**/*__Optics*.class")
},
)
}
How does it work?
It seems like Jacoco uses .class files to generate coverage. Check in your build folder for these files.
Here, you can see we have the .class
file, that we can exclude
in the jacocoTestReport
block with the correct glob format.