sonar.coverage.jacoco.xmlReportPaths not reporting coverage

Hi,
We are currently using SonarCloud to publish our coverage reports to from a Kotlin project.

// build.gradle

plugins {
    java
    kotlin("jvm") version "1.3.71"
    jacoco
    id("org.sonarqube") version "2.7"
}

sonarqube {
    properties {
        property("sonar.login", "****")
        property("sonar.host.url", "https://sonarcloud.io")
        property("sonar.organization", "<org>")
        property("sonar.projectName", "<project>")
        property("sonar.projectKey", "<org_project>")
        property("sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml")
        property("sonar.sources", "src/main")
        property("sonar.tests", "src/test")
    }
}

tasks.jacocoTestReport {
    dependsOn("test")
    dependsOn("integrationTest")

    executionData(file("$buildDir/jacoco/test.exec"), file("$buildDir/jacoco/integrationTest.exec"))
    reports {
        xml.isEnabled = true
        html.isEnabled = true
    }
}

Running $ gradlew jacocoTestCoverage sonarqube correctly generates the coverage report with the following build output:

output.log (102.2 KB)

Snippet

2020-05-25T15:22:52.008+0200 [INFO] [org.sonarqube.gradle.SonarQubeTask] Sensor JaCoCo XML Report Importer [jacoco]
2020-05-25T15:22:52.008+0200 [INFO] [org.sonarqube.gradle.SonarQubeTask] Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
2020-05-25T15:22:52.008+0200 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Reading report '<BASE_DIR>/build/reports/jacoco/test/jacocoTestReport.xml'
2020-05-25T15:22:52.040+0200 [INFO] [org.sonarqube.gradle.SonarQubeTask] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=35ms

Generated Report:

However on SonarCloud we have no coverage reported at all:

I’ve already tried following the guides on the community forum and now am running out of ideas what could it possibly be.
JaCoCo plugin seems to be enabled and the debug reports state that the report is correctly read and I can confirm that the coverage file exists.

Any help is appreciated, thanks!

Regards,
Nisheeth Barthwal

Hello @nbaztec,

Thanks for the detailed submission!
Could you try to upgrade the org.sonarqube plugin to 2.8? We made some changes in the latest version where we drop the support of the .exec format in favour of the .xml format of jacoco reports (see this ticket for more information).

1 Like

Hi @TomVanBraband

Thanks for looking in, I’ve bumped the version to 2.8 (it was previously 2.8 but I wanted to try 2.7 as they are defined in the examples on the github repo)

Nothing changed on my end, the logs still state the same and I presume I’m not using the .exec files for sonarqube at all (only to merge execution results for jacoco).

Any further suggestions? It’s a quite unfortunate not having our coverage reports in sonarcloud.

Thanks

Do the file paths in the JaCoCo report don’t match the relative paths used in SonarQube?
Any chance you could provide us a simple reproducer?

As per the logs it seems to have found, read and imported the report.

It’s a bit hard to have a sample producer since this is a private repository, hence I’ve attached the gradle settings, and snippets from the file system and the logs.

I’ll see what I can do.

Thanks!

--------- EDIT

I re-read the comment and checked the generated coverage report. I can identify one factor that the directory structure of our main package does not match the namespace.

src/main/kotlin/Main.kt defines the root package as io.foo.bar and that’s reflected all over the coverage report.

Just confirmed. https://github.com/SonarSource/sonar-jacoco/blob/master/src/main/java/org/sonar/plugins/jacoco/FileLocator.java#L44

Moving the files to the java-style directory structure seemed to work and coverage was reported.

Is this a known bug and/or will this be fixed? Since kotlin packages don’t require (and is suggested as well) complete directory names.

Thanks.

Yes, looks like it’s a case we didn’t consider.

I created a ticket: https://jira.sonarsource.com/browse/JACOCO-16

Thanks for reporting the problem.

1 Like

Thanks for opening the issue! Looking forward to having it fixed.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.