Sonar and jacoco full report configuration for gradle

We have a multi module gradle java project on bitbucket cloud that we integrate sonarcloud plus jacoco full report.

we have a jacoco full report task in the root project as in this example:

it writes the report to $rootDir/build/reports/jacoco/jacocoFullReport/jacocoFullReport.xml

we configure sonarqube in the root project:

sonarqube {
properties {
property “sonar.projectName”, “…”
property “sonar.projectDescription”,"…"
property “sonar.projectKey”, “…”
property “sonar.coverage.jacoco.xmlReportPaths”, “$rootDir/build/reports/jacoco/jacocoFullReport/jacocoFullReport.xml”

jacoco generates a report for every individual project, then the full report task aggregates all execution data from all sub modules and creates a full report.
the individual jacoco reports for each module are ok but jacoco doesn’t consider classes from other modules in the report although they are covered. the full report task does it because it sees all execution data from all sub projects.

with this setup sonarqube task uploads to sonrcloud the individual reports which are not complete.

adding a sonarqube configuration to each subproject with a path to the full report solves it:
sonarqube {
properties {
property ‘sonar.coverage.jacoco.xmlReportPaths’, “${project.rootDir}/build/reports/jacoco/jacocoFullReport/jacocoFullReport.xml”

now the coverage in sonarcloud is full, but sonarqube task complains:

No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths=‘MyProject path…/build/reports/jacoco/jacocoFullReport.xml’. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml

and that’s correct because the full report doesn’t exist yet while sonar is analysing submodules.

my question is if that is the correct way to configure sonar with jacoco full report and should we ignore the sonar complains?

Hey there.

Reading through your topic, I think there might be some misunderstood cause/effect of the various changes you’ve made.

Just to make sure I understand,the jacocoFullReport.xml file exists prior to any SonarQube analysis starting, is that correct? Stated another way, the aggregation is done before SonarQube analysis starts?

I’m asking this to understand if something is somehow happening in parallel (you have the aggregation happening while SonarQube begins analysis), or if everything is happening serially (SonarQube analysis starts after everything else is completed).