I am writing gradle plugin using kotlin. I have test project which uses this plugin. The test project includes generation of java classes from openapi generation. The directory of generated classes (/build/generated/swagger) will be added to main source set. If I use my plugin, which defines, jacoco plugin it includes these sources into coverage calculation and sonar then fails. So my idea to exclude any sources from build directory already in plugin.
I tried something like this:
project.afterEvaluate {
project.tasks.withType<JacocoReport> {
val jacocoDir = project.layout.buildDirectory.dir("jacoco").get()
executionData.from(jacocoDir.file("test.exec"), jacocoDir.file("integrationTest.exec"))
classDirectories.setFrom(classDirectories.files.map {
project.fileTree(it) {
exclude(
"**/build/**",
"build/**",
"**/generated/**"
)
}
})
}
}
but I still see generated classes in jacoco report.