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:
https://github.com/SonarSource/sonar-scanning-examples/blob/master/sonarqube-scanner-gradle/gradle-multimodule-coverage/build.gradle
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?