Gradle plugin ignores sonar.jacoco.reportPaths

SonarQube 6.7 (build 33306) Enterprise Edition
Gradle plugin 2.7
SonarJava 4.15.0.12310

Steps to reproduce:

  1. Create a gradle project that contains some unit tests and has the “jacoco” plugin applied to generate coverage data
  2. Specify “sonar.jacoco.reportPaths” property to point to a different location than the unit test output
  3. Run SonarQube analysis

Expected:
SonarQube should use the data from the files specified in the property

Observed:
SonarQube always uses the output from the gradle test task (build/jacoco/test.exec by default) if it exists, ignoring the property (more accurately, it always uses the first execution data file in its search list, and that is always the unit test output)

Background
I’m using the jacocoMerge task from the jacoco Gradle plugin to merge unit and integration test coverage data as well as coverage from several sub-modules (so that if a class is in one sub-project but tested in another it still counts), but the only way to get SonarQube to use the merged data is to delete the unit test coverage data before running analysis. This is cumbersome and problematic, as re-running analysis will do the merge without the unit test data.

1 Like

Hi,

How are you specifying the location? In your gradle properties or on the command line?

 
Ann

In the build file with a properties configuration closure:

sonarqube {
  properties {
    property "sonar.jacoco.reportPaths", "${rootProject.buildDir}/jacoco/jacocoMerge.exec"
  }
}

Hi,

This is probably a dumb question, but are you sure ${rootProject.buildDir} has the value you expect?

 
Ann

Yes, since the logs indicate it’s used for any projects without a “build/jacoco/test.exec” but for those that do, that’s used in preference.

I have written a self-contained test project that reproduces the error but company policy doesn’t allow me to post code publicly. Is there a way to raise the bug through email or a password-protected site? We are a paying customer.

Bump… anything we can do here?

Hi Stefanos, I’ll send you a private message so that you can reply and send the reproducer privately.