Sonar Scanner not finding jacoco.xml file in multi-module maven project

We use Maven to build our apps and have a large number of modules in each of the apps.
I have 2 fold question:

  • List item
    Based on the example project (https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonarqube-scanner-maven/maven-multimodule), this requires a new maven module to be added in order to aggregate reports from all other modules. This is extremely intrusive and hence I would like to know if this is the only recommended approach? If not, Can you please suggest how to aggregate reports without creating a new module?

  • List item
    After adding a new Maven module, I am able to generate the aggregated XML file (jacco.xml) successfully on my local machine. However, Sonar sensor is unable to find the XML file and hence reporting it as ZERO files found for scanning. I am not seeing any analysis reports in SonarQube UI. SonarQube shows that zero files were found in the source code But indicates that analysis was successful.

Versions used:

  • sonarqube 8.4.1
  • jacoco-maven-plugin : 0.8.6
  • sonar.maven.plugin.version=3.7.0.1746
  • maven 3.3.9
  • language Java
  • openjdk 8 ( source code version)

Parent Pom file setting:
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<aggregate.report.dir>sonar-module/target/site/jacoco-aggregate/jacoco.xml</aggregate.report.dir>
<sonar.language>java</sonar.language>

  <plugin>
    <groupId>org.sonarsource.scanner.maven</groupId>
    <artifactId>sonar-maven-plugin</artifactId>
    <version>3.7.0.1746</version>
  </plugin>
  <plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.6</version>
    <executions>
      <execution>
        <id>prepare-agent</id>
        <goals>
          <goal>prepare-agent</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

Relevant lines from the verbose log output from executing the command:
mvn -X clean install
mvn -X sonar:sonar -Dsonar.verbose=true

[INFO] 16:44:58.896 ------------- Run sensors on project
[DEBUG] 16:44:58.898 'Generic Coverage Report' skipped because one of the required properties is missing
[DEBUG] 16:44:58.899 'Java CPD Block Indexer' skipped because there is no related file in current project
[DEBUG] 16:44:58.899 Sensors : Zero Coverage Sensor
[INFO] 16:44:58.899 Sensor Zero Coverage Sensor
[INFO] 16:44:58.903 Sensor Zero Coverage Sensor (done) | time=4ms
[INFO] 16:44:58.906 CPD Executor Calculating CPD for 0 files
[INFO] 16:44:58.907 CPD Executor CPD calculation finished (done) | time=0ms
...
[DEBUG] 16:44:59.349 POST 200 https://sonarqube.xxx.com/api/ce/submit?projectKey=xxx&projectName=xxx | time=215ms
[INFO] 16:44:59.350 Analysis report uploaded in 216ms
[DEBUG] 16:44:59.351 Report metadata written to /myproject/target/sonar/report-task.txt
[INFO] 16:44:59.352 ANALYSIS SUCCESSFUL, you can browse https://sonarqube.xxx.com/dashboard?id=xxx

Can you please help?

Hello @Smitha_Rao

if this is the only recommended approach?

The only other solution (not recommended, but it should still work) that I know of is to split into two maven commands. Example.

A first maven command collect the coverage of all modules in the same .exec file:
$ mvn clean install
A second maven command generate the JaCoCo XML report and send it to SonarQube:
$ mvn jacoco:report sonar:sonar

According to the relevant log lines you linked, I don’t think you are looking at the right place for jacoco coverage logs. It should look like:

INFO: Sensor JaCoCo XML Report Importer [jacoco]
// ...
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms

Do you see any useful information between those two lines?

Thanks Quentin. I will try the suggestion of working with .exec file generation first and then converting and publishing that as XML file .
I am including details from logs related to SonarQube sensor analysis. I was not able to find the exact line you have indicated in your response. However it might be because of some other issues highlighted in the logs ?

My understanding is that the sensor is unable to identify that this is a Java project ? or its looking for some property that i have not set ? Not sure what is missing. Any pointer is helpful .

[INFO] 16:41:04.030 0 files ignored because of scm ignore settings
[INFO] 16:41:04.030 ------------- Run sensors on module LumiraDx xxx Webapp
[INFO] 16:41:04.050 Load metrics repository
[DEBUG] 16:41:04.185 GET 200 https://sonarqube.xxx.com/api/metrics/search?f=name,description,direction,qualitative,custom&ps=500&p=1 | time=135ms
[INFO] 16:41:04.194 Load metrics repository (done) | time=144ms
[DEBUG] 16:41:04.233 'Import external issues report' skipped because one of the required properties is missing
[DEBUG] 16:41:04.236 'gcov' skipped because there is no related file in current project
[DEBUG] 16:41:04.236 'llvm-cov' skipped because there is no related file in current project
[DEBUG] 16:41:04.237 'cppunit' skipped because there is no related file in current project
[DEBUG] 16:41:04.237 'VisualStudioCoverage' skipped because there is no related file in current project
[DEBUG] 16:41:04.238 'bullseye' skipped because there is no related file in current project
[DEBUG] 16:41:04.238 'YAML Sensor' skipped because there is no related file in current project
[DEBUG] 16:41:04.238 Sensors : 
[INFO] 16:41:04.241 ------------- Run sensors on module LumiraDx xxx Service Common
[DEBUG] 16:41:04.245 'Import external issues report' skipped because one of the required properties is missing
[DEBUG] 16:41:04.246 'gcov' skipped because there is no related file in current project
[DEBUG] 16:41:04.246 'llvm-cov' skipped because there is no related file in current project
[DEBUG] 16:41:04.246 'cppunit' skipped because there is no related file in current project
[DEBUG] 16:41:04.246 'VisualStudioCoverage' skipped because there is no related file in current project
[DEBUG] 16:41:04.246 'bullseye' skipped because there is no related file in current project
[DEBUG] 16:41:04.246 'YAML Sensor' skipped because there is no related file in current project
[DEBUG] 16:41:04.246 Sensors : 
[INFO] 16:41:04.246 ------------- Run sensors on module LumiraDx xxx Service API Client (Swagger SDK based)
[DEBUG] 16:41:04.250 'Import external issues report' skipped because one of the required properties is missing
[DEBUG] 16:41:04.250 'gcov' skipped because there is no related file in current project
[DEBUG] 16:41:04.250 'llvm-cov' skipped because there is no related file in current project
[DEBUG] 16:41:04.250 'cppunit' skipped because there is no related file in current project
[DEBUG] 16:41:04.250 'VisualStudioCoverage' skipped because there is no related file in current project
[DEBUG] 16:41:04.250 'bullseye' skipped because there is no related file in current project
[DEBUG] 16:41:04.250 'YAML Sensor' skipped because there is no related file in current project
[DEBUG] 16:41:04.250 Sensors : 
[INFO] 16:41:04.251 ------------- Run sensors on module sonar
[DEBUG] 16:41:04.256 'Import external issues report' skipped because one of the required properties is missing
[DEBUG] 16:41:04.256 'gcov' skipped because there is no related file in current project
[DEBUG] 16:41:04.256 'llvm-cov' skipped because there is no related file in current project
[DEBUG] 16:41:04.256 'cppunit' skipped because there is no related file in current project
[DEBUG] 16:41:04.256 'VisualStudioCoverage' skipped because there is no related file in current project
[DEBUG] 16:41:04.256 'bullseye' skipped because there is no related file in current project
[DEBUG] 16:41:04.256 'YAML Sensor' skipped because there is no related file in current project
[DEBUG] 16:41:04.256 Sensors : 
[INFO] 16:41:04.256 ------------- Run sensors on module LumiraDx xxx Service Core
[DEBUG] 16:41:04.261 'Import external issues report' skipped because one of the required properties is missing
[DEBUG] 16:41:04.262 'gcov' skipped because there is no related file in current project
[DEBUG] 16:41:04.262 'llvm-cov' skipped because there is no related file in current project
[DEBUG] 16:41:04.262 'cppunit' skipped because there is no related file in current project
[DEBUG] 16:41:04.262 'VisualStudioCoverage' skipped because there is no related file in current project
[DEBUG] 16:41:04.262 'bullseye' skipped because there is no related file in current project
[DEBUG] 16:41:04.262 'YAML Sensor' skipped because there is no related file in current project
[DEBUG] 16:41:04.262 Sensors : 
[INFO] 16:41:04.262 ------------- Run sensors on module LumiraDx xxx Service Distribution Assembly
[DEBUG] 16:41:04.266 'Import external issues report' skipped because one of the required properties is missing
[DEBUG] 16:41:04.266 'gcov' skipped because there is no related file in current project
[DEBUG] 16:41:04.266 'llvm-cov' skipped because there is no related file in current project
[DEBUG] 16:41:04.266 'cppunit' skipped because there is no related file in current project
[DEBUG] 16:41:04.266 'VisualStudioCoverage' skipped because there is no related file in current project
[DEBUG] 16:41:04.266 'bullseye' skipped because there is no related file in current project
[DEBUG] 16:41:04.267 'YAML Sensor' skipped because there is no related file in current project
[DEBUG] 16:41:04.267 Sensors : 
[INFO] 16:41:04.267 ------------- Run sensors on module LumiraDx xxx Service
[DEBUG] 16:41:04.272 'Import external issues report' skipped because one of the required properties is missing
[DEBUG] 16:41:04.272 'gcov' skipped because there is no related file in current project
[DEBUG] 16:41:04.272 'llvm-cov' skipped because there is no related file in current project
[DEBUG] 16:41:04.273 'cppunit' skipped because there is no related file in current project
[DEBUG] 16:41:04.273 'VisualStudioCoverage' skipped because there is no related file in current project
[DEBUG] 16:41:04.273 'bullseye' skipped because there is no related file in current project
[DEBUG] 16:41:04.273 'YAML Sensor' skipped because there is no related file in current project
[DEBUG] 16:41:04.274 'Generic Test Executions Report' skipped because one of the required properties is missing
[DEBUG] 16:41:04.274 'CFamily' skipped because there is no related file in current project
[DEBUG] 16:41:04.274 Sensors : 
[INFO] 16:41:04.274 ------------- Run sensors on project
[DEBUG] 16:41:04.277 'Generic Coverage Report' skipped because one of the required properties is missing
[DEBUG] 16:41:04.277 'Java CPD Block Indexer' skipped because there is no related file in current project
[DEBUG] 16:41:04.277 Sensors : Zero Coverage Sensor
[INFO] 16:41:04.278 Sensor Zero Coverage Sensor
[INFO] 16:41:04.282 Sensor Zero Coverage Sensor (done) | time=5ms
[INFO] 16:41:04.285 CPD Executor Calculating CPD for 0 files
[INFO] 16:41:04.285 CPD Executor CPD calculation finished (done) | time=0ms