# The JaCoCo Plugin

The JaCoCo plugin is currently incubating. Please be aware that the DSL and other configuration may change in later Gradle versions.

The JaCoCo plugin provides code coverage metrics for Java code via integration with JaCoCo.

## Getting Started

To get started, apply the JaCoCo plugin to the project you want to calculate code coverage for.

If the Java plugin is also applied to your project, a new task named `jacocoTestReport` is created that depends on the `test` task. The report is available at ``$buildDir`/reports/jacoco/test`. By default, a HTML report is generated.

## Configuring the JaCoCo Plugin

The JaCoCo plugin adds a project extension named `jacoco` of type , which allows configuring defaults for JaCoCo usage in your build.

## Gradle defaults for JaCoCo properties

Property | Gradle default
reportsDir | “`$buildDir`/reports/jacoco”

## JaCoCo Report configuration

The task can be used to generate code coverage reports in different formats. It implements the standard Gradle type and exposes a report container of type .

## JaCoCo specific task configuration

The JaCoCo plugin adds a extension to all tasks of type . This extension allows the configuration of the JaCoCo specific properties of the test task.

## Default values of the JaCoCo Task extension

Property | Gradle default
enabled | true
destPath | `$buildDir`/jacoco
append | true
includes | []
excludes | []
excludeClassLoaders | []
includeNoLocationClasses | false
sessionId | `auto-generated`
dumpOnExit | `true`
output | `Output.FILE`
address | `-`
port | `-`
classDumpPath | `-`
jmx | `false`

While all tasks of type are automatically enhanced to provide coverage information when the `java` plugin has been applied, any task that implements can be enhanced by the JaCoCo plugin. That is, any task that forks Java processes can be used to generate coverage information.

For example you can configure your build to generate code coverage using the `application` plugin.

build/jacoco/run.exec build/reports/jacoco/applicationCodeCoverageReport/html/index.html

## Tasks

For projects that also apply the Java Plugin, The JaCoCo plugin automatically adds the following tasks:

## JaCoCo plugin - tasks

Task name | Depends on | Type | Description
`jacocoTestReport` | - |  | Generates code coverage report for the test task.

## Dependency management

The JaCoCo plugin adds the following dependency configurations:

## JaCoCo plugin - dependency configurations

Name | Meaning
`jacocoAnt` | The JaCoCo Ant library used for running the `JacocoReport` and `JacocoMerge` tasks.
`jacocoAgent` | The JaCoCo agent library used for instrumenting the code under test.