Skip to content

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

License

Notifications You must be signed in to change notification settings

remal-gradle-plugins/jacoco-to-cobertura

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Important

JaCoCo Coverage Reports feature is generally available in GitLab 17.6.

If you use this plugin for GitLab's Cobertura Coverage Reports, 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.11.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
}