> For the complete documentation index, see [llms.txt](https://cover-docs.diffblue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cover-docs.diffblue.com/features/cover-reports/cover-reports-contributor/java-project-config.md).

# Java project config (JaCoCo)

JaCoCo reports are an essential component of Cover Reports. Some projects have access to a version of JaCoCo that Cover can use, either through their original configuration or via Cover itself (using Maven). However, if Cover cannot find a suitable JaCoCo configuration (typically detected during [Preflight checks](/features/cover-cli/project-configuration/preflight.md)), the following minor configuration update for your projects to add the appropriate dependencies and plugins (if you're not already using JaCoCo) should be sufficient.

{% tabs %}
{% tab title="Maven" %}
Add the following declarations to the `pom.xml` file for the project. The dependency ensures that JaCoCo is available for Cover to use for coverage and reporting analysis. The plugin below configures the JaCoCo plugin to provide reporting information when running tests on the project.

```xml
<dependency>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.8.7</version>
</dependency>
```

```xml
<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.8.7</version>
  <executions>
    <execution>
      <goals>
        <goal>prepare-agent</goal>
      </goals>
    </execution>
    <execution>
      <id>report</id>
      <phase>test</phase>
      <goals>
        <goal>report</goal>
      </goals>
    </execution>
  </executions>
</plugin>
```

{% endtab %}

{% tab title="Gradle (GROOVY)" %}

1. Add the JaCoCo plugin to your build script (`build.gradle` or `build.gradle.kts`):

```
apply plugin: 'jacoco'
```

2. Include the following configuration to enable the generation of the XML reports:

```
jacocoTestReport {
   dependsOn test
   reports {
       xml.required = true
       csv.required = true
   }
}
```

3. To ensure that you run JaCoCo, we recommend adding `finalizedBy jacocoTestReport` to your test configuration, for example:

```
test {
    finalizedBy jacocoTestReport
}
```

{% endtab %}

{% tab title="Gradle (KOTLIN)" %}

1. Add the JaCoCo plugin to your build script (`build.gradle` or `build.gradle.kts`):

```
plugins {
  jacoco
}
```

2. Include the following configuration to enable the generation of the XML reports:

```
tasks {
  jacocoTestReport {
    dependsOn(test)
    reports {
      xml.required.set(true)
      csv.required.set(true)
    }
  }
}
```

3. To ensure that you run JaCoCo, we recommend adding `finalizedBy jacocoTestReport` to your test configuration, for example:

```
test {
    finalizedBy jacocoTestReport
}
```

{% endtab %}
{% endtabs %}
