JaCoCo Coverage File and Append Mode | Generated by AI

Home 2025.10

That’s a subtle but important detail in how JaCoCo works.

Behavior of jacoco:prepare-agent

What happens if the file already exists?

How to append instead

If you want multiple runs to accumulate into the same exec file, you must explicitly enable append mode:

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.8.12</version>
  <configuration>
    <destFile>${project.build.directory}/jacoco-it.exec</destFile>
    <append>true</append>   <!-- ✅ append coverage data -->
  </configuration>
</plugin>

With <append>true>, if the file exists, the new coverage data will be merged into it.

So in short


Do you want me to also explain how this interacts with multi-module Maven builds (where each module may try to write its own JaCoCo exec), since that’s often why people hit overwrite vs append issues?


Back

openai/gpt-5

Donate