Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/remal-gradle-plugins/jacoco-to-cobertura

Convert Jacoco XML reports to Cobertura format for importing in GitLab CI coverage report artifact
https://github.com/remal-gradle-plugins/jacoco-to-cobertura

cobertura gradle gradle-plugin jacoco jacoco-to-cobertura plugin

Last synced: about 1 month ago
JSON representation

Convert Jacoco XML reports to Cobertura format for importing in GitLab CI coverage report artifact

Awesome Lists containing this project

README

        

> [!IMPORTANT]
> [JaCoCo Coverage Reports](https://docs.gitlab.com/ee/ci/testing/test_coverage_visualization/jacoco.html) feature is generally available in GitLab 17.6.
>
> If you use this plugin for GitLab's [Cobertura Coverage Reports](https://docs.gitlab.com/ee/ci/testing/test_coverage_visualization/cobertura.html), consider switching to JaCoCo Coverage Reports and removing this plugin from your build.

 

**Tested on Java LTS versions from 8 to 21.**

**Tested on Gradle versions from 6.1 to 8.12-rc-1.**

# `name.remal.jacoco-to-cobertura` plugin

[![configuration cache: supported](https://img.shields.io/static/v1?label=configuration%20cache&message=supported&color=success)](https://docs.gradle.org/current/userguide/configuration_cache.html)

For every [`JacocoReport`](https://docs.gradle.org/current/javadoc/org/gradle/testing/jacoco/tasks/JacocoReport.html) task,
this plugin creates a task that converts Jacoco XML report to Cobertura format.
This new task is executed automatically after corresponding `JacocoReport` task (via `finalizedBy`).

It can be useful for [GitLab test coverage visualization](https://docs.gitlab.com/ee/ci/testing/test_coverage_visualization.html).

The name of created task is `ToCobertura`. Examples:

* `jacocoTestReport` -> `jacocoTestReportToCobertura`
* `jacocoIntegrationTestReport` -> `jacocoIntegrationTestReportToCobertura`

By default, `*ToCobertura` tasks create XML files in the same directory where Jacoco XML report is.
Prefix `cobertura-` is added to the file name.
Example:

* `build/reports/jacoco/test/jacocoTestReport.xml` -> `build/reports/jacoco/test/cobertura-jacocoTestReport.xml`

## `jacocoToCoberturaTask` extension for `JacocoReport` tasks

This plugin add `jacocoToCoberturaTask` extension to all `JacocoReport` tasks.
This extension has type `TaskProvider`
and it's a provider of corresponding `*ToCobertura` task for the current `JacocoReport` task.

It can be used like this:

```groovy
tasks.withType(JacocoReport).configureEach {
println jacocoToCoberturaTask.name // prints corresponding name of `*ToCobertura` task
}
```