Skip to content
← Back to activity

Immutable solution version

JaCoCo coverage missing in SonarQube: use XML reports, not .exec

Version 2Sign in to save

Complete solution

Fix for JaCoCo coverage missing in SonarQube: use XML reports, not .exec: [accepted answer]: for a Gradle build, skip sonar-project.properties and let the jacoco and sonarqube plugins do the wiring: plugins { id "jacoco"; id "org.sonarqube" version "2. Use this when you hit exactly this in JaCoCo coverage missing in SonarQube. Not for different errors or different tools.

TL;DR: [accepted answer]: for a Gradle build, skip sonar-project.properties and let the jacoco and sonarqube plugins do the wiring: plugins { id "jacoco"; id "org.sonarqube" version "2.8" } Enable the JaCoCo XML report (SonarQube only reads the XML now): jacocoTestReport { reports { xml.enabled true } } Then run gradle build jacocoTestReport sonarqube so the XML report exists before analysis starts.

JaCoCo coverage missing in SonarQube: use XML reports, not .exec

Fix

  1. [accepted answer]: for a Gradle build, skip sonar-project.properties and let the jacoco and sonarqube plugins do the wiring: plugins { id "jacoco"; id "org.sonarqube" version "2.8" } Enable the JaCoCo XML report (SonarQube only reads the XML now): jacocoTestReport { reports { xml.enabled true } } Then run gradle build jacocoTestReport sonarqube so the XML report exists before analysis starts. Expected: this specific failure stops.

  2. Set other options in the sonarqube extension in build.gradle instead of properties files, e.g. sonar.exclusions for generated code. Expected: this specific failure stops.

  3. The old binary .exec report path is ignored by modern SonarQube, so if coverage is missing, check the report format first. Expected: this specific failure stops.

Details

Context: Stack Overflow #58839685 (accepted answer, 33 votes): SonarQube 7.7 warns that sonar.jacoco.reportPath (the JaCoCo binary .exec format) is deprecated and that sonar.coverage.jacoco.xmlReportPaths (XML format) should be used instead. The asker's Gradle project pointed the old property at build/jacoco/test.exec and coverage was not picked up.

When to use

You hit exactly this: JaCoCo coverage missing in SonarQube: use XML reports, not .exec in JaCoCo coverage missing in SonarQube.

When not to use

A different error, or the same symptom in a different tool. This page only covers the failure above.

Compatibility

JaCoCo coverage missing in SonarQube (versions mentioned here: 7.7, 2.8).

Evidence

Stack Overflow #58839685 (accepted answer, 33 votes): SonarQube 7.7 warns that sonar.jacoco.reportPath (the JaCoCo binary .exec format) is deprecated and that sonar.coverage.jacoco.xmlReportPaths (XML format) should be used instead. The asker's Gradle project pointed the old property at build/jacoco/test.exec and coverage was not picked up.

Verified resolution: [accepted answer]: for a Gradle build, skip sonar-project.properties and let the jacoco and sonarqube plugins do the wiring:

plugins { id "jacoco"; id "org.sonarqube" version "2.8" }

Enable the JaCoCo XML report (SonarQube only reads the XML now):

jacocoTestReport { reports { xml.enabled true } }

Then run gradle build jacocoTestReport sonarqube so the XML report exists before analysis starts. Set other options in the sonarqube extension in build.gradle instead of properties files, e.g. sonar.exclusions for generated code. The old binary .exec report path is ignored by modern SonarQube, so if coverage is missing, check the report format first.

Source: https://stackoverflow.com/questions/58839685

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_ME6b0PLfx9T7fW6qXxLO3w" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">JaCoCo coverage missing in SonarQube: use XML reports, not .exec <span>— Vectle</span></a>