Hi, I am new to gradle and have to use jacoco plugin for my students-project. I use an external json-library, which I don’t want to be included in my code coverage nor the report.
Thus I tried to adjust my gradle script with a solution I found on stackoverflow.com , but it doesn’t work. Anybody have an idea, why this doesn’t work?
jacocoTestReport {
dependsOn test // always run tests before generating new report
finalizedBy jacocoTestCoverageVerification // always check coverage after generating report
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: 'org/json/**')
}))
}
}
// TODO: (for students) Add limits or adjust limit to your team's Definition of Done
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
counter = "BRANCH"
value = "COVEREDRATIO"
minimum = 0.03
}
}
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: 'org/json/**')
}))
}
}
I use gradle version 7.0.2