JaCoCo aggregate report for multi-module Maven and Gradle builds
Eight setups on a two-module project with JaCoCo 0.8.16, Maven and Gradle: which one reports code covered from another module.

A JaCoCo report per module counts only that module’s own tests. To see code in
one module covered by tests in another, add a separate module that depends on
all the others and runs report-aggregate in Maven, or apply
jacoco-report-aggregation in Gradle. An aggregate goal in the parent pom
writes an empty report.

Aggregate report setups at a glance
| Setup | What the report showed |
|---|---|
Per-module report only | Pricing 1 of 8 lines, though api’s tests ran 6 |
Maven: coverage module with report-aggregate, depends on every module | Pricing 6/8, Checkout 1/2 |
Maven: coverage module missing the api dependency | Pricing 1/8; api left out |
Maven: report-aggregate in the parent pom | Empty report |
Maven: mvn test instead of mvn verify | No aggregate report |
Gradle: jacoco-report-aggregation in a coverage project with a JacocoCoverageReport registered | Pricing 6/8, Checkout 1/2 |
Gradle: the same without the reporting block | Task 'testCodeCoverageReport' not found |
Gradle: plugin applied in api itself | Pricing 6/8, Checkout 1/2 |
We ran every setup with JaCoCo 0.8.16, Maven 3.9.16 and Gradle 9.7.1 on JDK
26. The project has two modules: core holds shop.core.Pricing with one
test for its format method, and api holds Checkout, whose two tests call
Pricing.total through Checkout.quote.
Why the per-module report misses lines
<execution><goals><goal>prepare-agent</goal></goals></execution>
<execution><id>report</id><phase>test</phase><goals><goal>report</goal></goals></execution>
With these executions in the parent pom, each module writes
target/site/jacoco. core’s report showed Pricing at 1 of 8 lines: only
format. The api tests did run total, and their jacoco.exec recorded
it, but that file sits in api/target, and api’s own report covers only
api’s classes.
Maven: a separate module for report-aggregate
<project>
<parent>…shop-parent…</parent>
<artifactId>coverage</artifactId>
<packaging>pom</packaging>
<dependencies>
<dependency><groupId>shop</groupId><artifactId>core</artifactId><version>1.0.0</version></dependency>
<dependency><groupId>shop</groupId><artifactId>api</artifactId><version>1.0.0</version></dependency>
</dependencies>
<build><plugins><plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>aggregate</id><phase>verify</phase>
<goals><goal>report-aggregate</goal></goals>
</execution>
</executions>
</plugin></plugins></build>
</project>
Add <module>coverage</module> to the parent and run mvn verify. The
report lands in coverage/target/site/jacoco-aggregate, with Pricing at 6
of 8 lines and Checkout at 1 of 2. report-aggregate reads the execution
data and classes of the module’s dependencies, so every module has to be a
dependency; with core alone, Pricing dropped back to 1/8 and Checkout
was gone.

Why the Maven aggregate report is empty
| What we tried | What happened |
|---|---|
report-aggregate in the parent pom | target/site/jacoco-aggregate with no classes |
The same execution, inherited by api | Pricing 6/8, but no Checkout |
mvn test | No aggregate report: it is bound to verify |
coverage without the api dependency | api’s tests and classes left out |
The parent builds before its modules and depends on none of them, so its
aggregate report had nothing to read. The goal also leaves out the module it
runs in: inherited by api, it reported core’s Pricing and not api’s
own Checkout. A module of its own avoids both.
Gradle: jacoco-report-aggregation
// coverage/build.gradle.kts
plugins {
base
`jacoco-report-aggregation`
}
repositories { mavenCentral() }
dependencies {
jacocoAggregation(project(":core"))
jacocoAggregation(project(":api"))
}
reporting {
reports {
register<JacocoCoverageReport>("testCodeCoverageReport") {
testSuiteName = "test"
}
}
}
gradle testCodeCoverageReport ran both projects’ tests and wrote
coverage/build/reports/jacoco/testCodeCoverageReport with Pricing 6/8 and
Checkout 1/2. Without the reporting block the task does not exist, and
Gradle stops with “Task ‘testCodeCoverageReport’ not found”. Listing only
:api was enough here, because api depends on core; listing only :core
left api’s tests out.
In a project that already applies java, the plugin registers the task by
itself. Applied in api, gradle testCodeCoverageReport aggregated api
and core with no reporting block. gradle test alone writes no
aggregate report.
What Supercov adds
npx supercov -- mvn test
npx supercov runs latest gaps
Supercov measured both modules in one run, with no aggregation module: the 3
tests across core and api, Pricing.total covered by the api tests, and
one line left, the throw for a quantity of zero. It also showed that
member && sum >= 10_000 was never run with member false, an MC/DC gap the
line counts hide. See JaCoCo report not
generated when there is no report at all,
and Java code coverage tools for the
alternatives.
More coverage guides
- Jest coverageThreshold: global, per-folder and per-file
- pytest ignore directory: --ignore, norecursedirs and collect_ignore
- Merge coverage reports from shards: Vitest, Jest and coverage.py
- Statement vs branch coverage, with decision, line and path coverage
- JaCoCo report not generated: the causes in Maven and Gradle
- Kover exclude: classes, packages and generated code
- sonar.coverage.exclusions: why SonarQube ignores your JaCoCo excludes
- istanbul ignore next vs c8 ignore next: every hint, measured
- Go test coverage exclude: files, packages and mocks
- Jest coverage exclude: files, folders and lines
- pytest coverage exclude: omit files, folders and lines
- Vitest coverage exclude: files, folders and lines
- JaCoCo exclude in Maven and Gradle: packages, classes and generated code