# The JaCoCo Report Aggregation Plugin

version 8.14.5-20260326091925+0000

The JaCoCo Report Aggregation plugin (plugin id: `jacoco-report-aggregation`) provides the ability to aggregate the results of multiple JaCoCo code coverage reports (potentially spanning multiple Gradle projects) into a single HTML report. The binary data backing the coverage reports are produced by Test task invocations; see more at the JaCoCo Plugin chapter.

## Usage

To use the JaCoCo Report Aggregation plugin, include the following in your build script:

    plugins {
        id 'jacoco-report-aggregation'
    }

    plugins {
        id("jacoco-report-aggregation")
    }

Note that this plugin takes no action unless applied in concert with the JVM Test Suite Plugin. The Java Plugin automatically applies the JVM Test Suite Plugin.

There are now two ways to collect code coverage results across multiple subprojects:

1. From the distribution’s project, such as an application or WAR subproject → distribution sample

2. Using a standalone project to specify subprojects → standalone sample

Example 2 could also be used to aggregate results via the root project.

| The JaCoCo Report Aggregation plugin does not currently work with the `com.android.application` plugin.

## Tasks

When the project also applies the `jvm-test-suite` plugin, the following tasks are added for each test suite:

`testSuiteCodeCoverageReport` — JacocoReport

  Depends on: Artifacts of variants matching the below attributes

  Collects variants of direct and transitive project dependencies via the `jacocoAggregation` configuration. The following Attributes will be matched:

        - org.gradle.category         = verification     (1)
        - org.gradle.testsuite.name   = test             (2)
        - org.gradle.verificationtype = jacoco-results   (3)

1 | Category attribute; value is fixed.
2 | TestSuiteName attribute; value is derived from TestSuite#getName().
3 | VerificationType attribute; value is fixed.

More information about the variants produced by test execution with JaCoCo are available in the Outgoing Variants section of the JaCoCo Plugin documentation.

## Reports

| By default, Gradle stops executing tasks when any task fails — including test failures. To ensure that your builds always generate aggregation reports, specify the `--continue` option in your Gradle command. For more information, see continuing the build when a failure occurs.

### Automatic report creation

When the project also applies the `jvm-test-suite` plugin, the following reporting objects are added for each test suite:

`testSuiteCodeCoverageReport` — JacocoCoverageReport

  Creates an aggregate Jacoco report aggregating all test suites with a given name across all project dependencies.

### Manual report creation

When the project does not apply the `jvm-test-suite` plugin, you must manually register one or more reports:

Example 1. Create a reporting container
build.gradle.kts

    reporting {
        reports {
            val testCodeCoverageReport by creating(JacocoCoverageReport::class) { (1)
                testSuiteName = "test"
            }
        }
    }

build.gradle

    reporting {
        reports {
            testCodeCoverageReport(JacocoCoverageReport) { (1)
                testSuiteName = "test"
            }
        }
    }

1 | Creates a report named `testCodeCoverageReport` of type `JacocoCoverageReport`, aggregating all test suites from all project dependencies with a given TestSuite#getName().

Report creation automatically creates backing tasks to aggregate coverage results for the given test suite type value.

## Dependency management

The JaCoCo Report Aggregation plugin adds the following dependency configurations:

Table 1. JaCoCo Report Aggregation plugin - dependency configurations
Name | Meaning
--- | ---
`jacocoAggregation` | The configuration used to declare all project dependencies having code coverage data to be aggregated.
`aggregateCodeCoverageReportResults` | Consumes the project dependencies from the `jacocoAggregation` configuration using variant-aware matching to find the appropriate test suite type.

It is not necessary to explicitly add dependencies to the `jacocoAggregation` configuration if the project also applies the `jvm-test-suite` plugin.