Skip to content

remal-gradle-plugins/jacoco-to-cobertura

Repository files navigation

Tested on Java LTS versions from 8 to 21.

Tested on Gradle versions from 6.1 to 8.8-rc-1.

name.remal.jacoco-to-cobertura plugin

configuration cache: supported

For every JacocoReport 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.

The name of created task is <jacoco task name>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<JacocoToCobertura> and it's a provider of corresponding *ToCobertura task for the current JacocoReport task.

It can be used like this:

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