Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

A JaCoCo report setting that worked in Gradle 7 fails in Gradle 8

ErrorjacocoTestReport fails after the Gradle 8 upgrade where it sets xml.enabled, html.enabled or csv.enabled

Short 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.

  • Applies to Gradle 8 and 9, JaCoCo plugin
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 .
  2. 2Match what you see, then jump to its fix

    1. 1The error appears after upgrading the Gradle wrapper from 7.x to 8.x.The build still sets enabled on a reportFix
    2. 2The failure names destination, or the report lands in an unexpected folder.A report folder is still set with destinationFix

What does the error look like?

  • jacocoTestReport fails after the Gradle 8 upgrade where it sets xml.enabled, html.enabled or csv.enabled
  • Report 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 --version

2Fix

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/reports

Confirmed by docs.gradle.org

Did this fix it?

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/jacocoHtml

Confirmed by docs.gradle.org

Did this fix it?

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

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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.