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

I’ve been looking over our build scan and found that all my subproject :test tasks are being executed. The reason given is that the JaCoCo agent is configured with ‘append = true’. I’ve applied the JaCoCo plugin as-is without any changes. Is this the expected behaviour or should I set ‘append = false’?

I’ve enabled build cache and I’m using Gradle 4.0.2.

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