Complete the code to apply the JaCoCo plugin in a Gradle build script.
plugins {
id '[1]'
}The JaCoCo plugin is applied in Gradle using id 'jacoco'.
Complete the code to set the JaCoCo tool version in Gradle.
jacoco {
toolVersion = '[1]'
}Setting toolVersion to a valid JaCoCo version like 0.8.7 ensures compatibility.
Fix the error in the test task configuration to generate JaCoCo reports.
tasks.test {
useJUnitPlatform()
finalizedBy('[1]')
}The finalizedBy should reference the jacocoTestReport task to generate coverage reports after tests.
Fill both blanks to configure the JaCoCo report formats in Gradle.
jacocoTestReport {
reports {
xml.required = [1]
html.required = [2]
}
}Setting both xml.required and html.required to true enables those report formats.
Fill all three blanks to exclude generated classes from JaCoCo coverage.
jacocoTestReport {
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect { file ->
fileTree(dir: file, exclude: [[1], [2], [3]])
}))
}
}Excluding generated classes like R.class, BuildConfig.class, and Manifest.class avoids counting them in coverage.