3
votes

I have a multi-module project and would like to visualize integration code coverage with SonarQube. I'm able to generate test.exec and integTest.exec (JaCoCo), but have problem to force sonar-runner (sonar-jacoco-plugin) to use them. sonar-runner reports:

Project coverage is set to 0% since there is no directories with classes.

which is true as for the root project (where integTest.exec is generated) doesn't have source files (but it should not be a problem for integration coverage). My configuration:

(...)
sonar.dynamicAnalysis=reuseReports
sonar.jacoco.reportPath=build/jacoco/test.exec
sonar.jacoco.itReportPath=build/jacoco/integTest.exec
sonar.modules=mod1,mod2
sonar.sources=src/main/java,src/main/resources
sonar.tests=src/test/java,src/test/groovy,src/test/resources
sonar.binaries=build/classes/main,build/resources/main

The project is built with Gradle, but due to a CI restrictions I need to use sonar-project.properties with sonar-runner configuration (not sonar-runner plugin from Gradle which worked for me in the past).

Update. After the analyze of sonar-jacoco-plugin sources I tried to just create a directory defined as a binary directory, but unfortunately sonar-runner doesn't set sonar.binaries property for a root module at all.

My question. Is there a workaround which would allow me to use file with the integration coverage data in a multi-module project with sonar-runner?

1

1 Answers

2
votes

As an ugly workaround I was able to configure report path to:

sonar.jacoco.reportPath=../build/jacoco/test.exec
sonar.jacoco.itReportPath=../build/jacoco/integTest.exec

and for second level modules (a module mod1 which has its own submodules mod1a and mod1b):

mod1.sonar.jacoco.reportPath=../../build/jacoco/test.exec
mod1.sonar.jacoco.itReportPath=../../build/jacoco/integTest.exec

Nevertheless it is very error prone and I hope someone else will have a better idea.