sonar.jacoco.reportPath not honoured by gradle sonarqube plugin (1.0)

749 views
Skip to first unread message

Chris Pollard

unread,
Jul 7, 2015, 12:00:30 PM7/7/15
to sona...@googlegroups.com
Hi there,

I've switched over to the sonarqube plugin but I have had difficulty producing coverage reports from JaCoCo.

It appears that the sonar.jacoco.reportPath is ignored and (guess) the default maven 'target/jacoco.exec' path is used instead.

When sonar.jacoco.reportPath is left unset and test.jacoco.destinationFile is left unset, the build will not analyse coverage data.
With sonar.jacoco.reportPath set t${project.buildDir}/jacoco/test.exec and test.jacoco.destinationFile is left unset, the build will not analyse coverage data.
With sonar.jacoco.reportPath set to anything and test.jacoco.destinationFile set to target/jacoco.exec, the coverage is analysed.


The following demonstrated best, with reportPath explicitly set to the jacoco default and destinationFile set to the undocumented (maven?) sonarqube location. This configuration will analyse the coverage data.

sonarqube {
    properties {
property "sonar.jacoco.reportPath", "${project.buildDir}/jacoco/test.exec" // this is the default as documented
property "sonar.log.level", "trace"
property "sonar.verbose", "true"
}
}

for the coverage analysis to occur, the test { jacoco { destinationFile } } has to be overriden:

test {
jacoco {
append = true
destinationFile = file("target/jacoco.exec")
classDumpFile = file("$buildDir/jacoco/classdumps")
}
}

And gives the following outputs:
...
Sonarqube property: sonar.jacoco.reportPath=/home/cpoll/Development/DevOps/Jenkins/sonarqube-gradle-test/build/jacoco/test.exec
...
16:45:15.077 INFO  - Sensor JaCoCoSensor...
16:45:15.079 INFO  - 	Checking binary directory: /home/cpoll/Development/DevOps/Jenkins/sonarqube-gradle-test/build/classes/main
16:45:15.079 INFO  - Analysing /home/cpoll/Development/DevOps/Jenkins/sonarqube-gradle-test/target/jacoco.exec
16:45:15.123 INFO  - Sensor JaCoCoSensor done: 46 ms
16:45:15.123 INFO  - Sensor JaCoCoOverallSensor...
...


Whereas the combination of

destinationFile =  file("${project.buildDir}/jacoco/test.exec")
property "sonar.jacoco.reportPath", "${project.buildDir}/jacoco/test.exec"

fails to do the coverage analysis (the Sensor JaCoCoSensor section is absent in the output and coverage data missing from uploaded analysis run)


Using
sonar 5.0
sonarqube 1.0
gradle 2.3
groovy 2.4.3

I've created a repo to show this in action:

hope this helps and good work on gradle and groovy support!
thanks
Chris

Julien HENRY

unread,
Jul 15, 2015, 6:06:36 AM7/15/15
to sona...@googlegroups.com, chris....@travisperkins.co.uk
Hi Chris,

We do not properly support automatic configuration for Groovy projects (only Java projects are supported). See http://jira.sonarsource.com/browse/SONARGRADL-7

In addition I think the correct property to have JaCoCo coverage on Groovy projects is sonar.groovy.jacoco.reportPath (see http://docs.sonarqube.org/display/PLUG/Groovy+Plugin)

++

Julien

Chris Pollard

unread,
Jul 21, 2015, 3:53:17 AM7/21/15
to sona...@googlegroups.com, chris....@travisperkins.co.uk
Thank you Julien,

I had not spotted the sonar.groovy.jacoco.reportPath which worked a treat, grand.

Cheers
Chris
Reply all
Reply to author
Forward
0 new messages