A JaCoCo report setting that worked in Gradle 7 fails in Gradle 8
jacocoTestReport fails after the Gradle 8 upgrade where it sets xml.enabled, html.enabled or csv.enabledShort answer
Gradle 8.0 removed the enabled and destination properties of report objects. In jacocoTestReport, set xml.required, html.required or csv.required to true or false instead, and use outputLocation for the folder.
Fix it fast
1Find out which cause you have
Search the build files for the old property names.
grep -rn "\.enabled\|\.destination\|isEnabled" --include=*.gradle --include=*.gradle.kts .2Match what you see, then jump to its fix
What does the error look like?
jacocoTestReport fails after the Gradle 8 upgrade where it sets xml.enabled, html.enabled or csv.enabledReport property destination no longer exists after the Gradle 8 upgrade
Cause 1 of 2
The build still sets enabled on a report
1Check
The Gradle 7 to 8 upgrade guide says the deprecated destination and enabled properties of the Report type were removed, and points to required and outputLocation.
./gradlew --version2Fix
Replace every enabled with required in the report block. Keep the value the same.
// build.gradle.kts
tasks.jacocoTestReport {
reports {
xml.required = true
html.required = true
csv.required = false
}
}
// build.gradle (Groovy)
jacocoTestReport {
reports {
xml.required = true
html.required = true
csv.required = false
}
}3Verify
Run the tests and the report task, then look for the report folder.
./gradlew test jacocoTestReport
ls build/reportsConfirmed by docs.gradle.org
Cause 2 of 2
A report folder is still set with destination
1Check
The destination property was removed together with enabled. The JaCoCo plugin page uses outputLocation with the layout API.
grep -rn "destination" --include=*.gradle --include=*.gradle.kts .2Fix
Use outputLocation and a path built from the project's build directory.
tasks.jacocoTestReport {
reports {
html.outputLocation = layout.buildDirectory.dir("jacocoHtml")
}
}3Verify
Run the report task and check the new folder.
./gradlew jacocoTestReport
ls build/jacocoHtmlConfirmed by docs.gradle.org
How do I stop it coming back?
- Run the build with --warning-mode all before every major Gradle upgrade so deprecations show up while they still work.
- Read the upgrading guide for the target major version first.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack end
Gradle runs no Cucumber scenarios from my feature files
Feature files exist under src/test but nothing runs
Cucumber runs on the JUnit Platform, so Gradle must call useJUnitPlatform() and have the cucumber-junit-platform-engine on the test classpath.
4 causes, each with a fixBack end
A Gradle build fails on classes that use Lombok annotations
Error: Annotation processors must be explicitly declared now.
Lombok is two things for Gradle: a compile-time library and an annotation processor.
3 causes, each with a fixBack end
Gradle cannot calculate the javaCompiler for compileJava
Failed to calculate the value of task ':compileJava' property 'javaCompiler'
The build asks for a Java toolchain version that Gradle cannot find on the machine.
2 causes, each with a fixBack end
Gradle cannot find org.codehaus.groovy:groovy for a Groovy 4 version
Could not find org.codehaus.groovy:groovy:4.0.12.
Groovy 4 and newer are published under the group org.apache.groovy.
2 causes, each with a fixBack end
Gradle 8 fails on Report destination: switch to outputLocation
What went wrong: 'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'
Gradle 8.0 removed the deprecated destination and enabled properties of the Report type.
2 causes, each with a fix