Работа с openjdk 11. Jacoco и gradle, оба являются новыми для меня. Мне нужно исключить некоторые классы из анализа теста Jacoco. Однако все, что я пытался, не исключало предполагаемые занятия. Вот фрагмент build.gradle:
jacoco {
toolVersion = "0.8.4"
reportsDir = file("${buildDir}/customJacocoReportDir")
}
jacocoTestCoverageVerification { // <==== Affects the build
violationRules {
rule {
element = 'PACKAGE'
limit {
counter = 'INSTRUCTION'jacoco {
toolVersion = "0.8.4"
reportsDir = file("${buildDir}/customJacocoReportDir")
}
jacocoTestCoverageVerification { // <==== Affects the build
violationRules {
rule {
element = 'PACKAGE'
limit {
counter = 'INSTRUCTION'
value = 'COVEREDRATIO'
minimum = 0.80 // <==== all packages have a 80% instruction coverage threshold
}
excludes = [ // <==== except these...
'com.mycomp.notification.adapter.models',
'com.mycomp.notification.adapter.serializers',
'com.mycomp.notification.adapter.properties',
'com.mycomp.notification.adapter',
'com.mycomp.notification.adapter.topology.configs',
'com.mycomp.notification.adapter.services.AdapterHttpClient.class',
'com.mycomp.notification.adapter.transformers.Transformer.class'
]
}
}
}
jacocoTestReport { // <==== Affects the coverage report
reports {
xml.enabled = true
html.enabled = true
}
// https://stackoverflow.com/questions/29887805/filter-jacoco-coverage-reports-with-gradle
// this version is compatible with Gradle 5 and 6
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: ['com/mycomp/notification/adapter/models/**',
'com/mycomp/notification/adapter/serializers/**',
'com/mycomp/notification/adapter/services/**',
'com/mycomp/notification/adapter/properties/**',
'com/mycomp/notification/adapter/topology/configs/**',
'com/mycomp/notification/adapter/transformers/Transformer.class'
])
}))
}
}
check.dependsOn jacocoTestCoverageVerification
test {
finalizedBy jacocoTestReport
jacoco {
excludes += ["com/mycomp/notification/adapter/transformers/Transformer.class",
"com/mycomp/notification/adapter/services/AdapterHttpClient.class"]
}
}
value = 'COVEREDRATIO'
minimum = 0.80 // <==== all packages have a 80% instruction coverage threshold
}
excludes = [ // <==== except these...
'com.mycomp.notification.adapter.models',
'com.mycomp.notification.adapter.serializers',
'com.mycomp.notification.adapter.properties',
'com.mycomp.notification.adapter',
'com.mycomp.notification.adapter.topology.configs',
'com.mycomp.notification.adapter.services.AdapterHttpClient.class',
'com.mycomp.notification.adapter.transformers.Transformer.class'
]
}
}
}
Могу ли я получить какое-либо понимание?