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

**URL:** <https://discuss.gradle.org/t/do-not-cache-if-condition-matched-jacoco-agent-configured-with-append-true-satisfied/23504>\
**Category:** Help/Discuss\
**Created:** [July 29, 2017, 5:17pm UTC](https://discuss.gradle.org/t/do-not-cache-if-condition-matched-jacoco-agent-configured-with-append-true-satisfied/23504 "2017-07-29T17:17:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christo\_Zietsman](https://avatars.discourse-cdn.com/v4/letter/c/cdc98d/32.png) [@Christo\_Zietsman](https://discuss.gradle.org/u/Christo_Zietsman)\
**Post date:** [July 29, 2017, 5:17pm UTC](https://discuss.gradle.org/t/do-not-cache-if-condition-matched-jacoco-agent-configured-with-append-true-satisfied/23504/1 "2017-07-29T17:17:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sterling](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/sterling/32/5395_2.png) [@sterling](https://discuss.gradle.org/u/sterling)\
**Post date:** [July 30, 2017, 8:43pm UTC](https://discuss.gradle.org/t/do-not-cache-if-condition-matched-jacoco-agent-configured-with-append-true-satisfied/23504/2 "2017-07-30T20:43:39Z")

</div>

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
gradle.taskGraph.whenReady { graph ->
    def enabled = graph.allTasks.any { it instanceof JacocoReport }
    tasks.withType(Test) {
        jacoco.enabled = enabled
    }
}

```
