Gradle plugin ignores sonar.jacoco.reportPaths

(Stefanos Piperoglou) #1

SonarQube 6.7 (build 33306) Enterprise Edition
Gradle plugin 2.7

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

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

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)

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
(G Ann Campbell) #2


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


(Stefanos Piperoglou) #3

In the build file with a properties configuration closure:

sonarqube {
  properties {
    property "sonar.jacoco.reportPaths", "${rootProject.buildDir}/jacoco/jacocoMerge.exec"
(G Ann Campbell) #4


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


(Stefanos Piperoglou) #5

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.

(Stefanos Piperoglou) #7

Bump… anything we can do here?

(Duarte Meneses) #10

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