Do-not-cache-if condition matched: JaCoCo agent configured with 'append=true' satisfied

Yes, this is a known limitation at the moment.

There are a couple of issues with JaCoCo that makes it harder to reliably cache the Test task and maintain backwards compatibility.

If you change append=false, you won’t be able to run tests in parallel because the JaCoCo agent will overwrite output files between test workers.

You’ll probably get more bang for your buck by only enabling JaCoCo analysis when you need it instead of all of the time.

Something like this should work (if you try to run with jacocoTestReport, it’ll enable the JaCoCo extension):

gradle.taskGraph.whenReady { graph ->
    def enabled = graph.allTasks.any { it instanceof JacocoReport }
    tasks.withType(Test) {
        jacoco.enabled = enabled
    }
}
1 Like