Sonar-maven-plugin not working with multi-module maven project jacoco reports


  • SonarCube version 8.9.6 (build 50800)
  • jacoco-maven-plugin version 0.8.5
  • sonar-maven-plugin
  • multi-module maven project

Maven project layout:

[root of project]
  +-- app
  +-- dbsync
  +-- mock-rest

Where app, dbsync, mock-rest are child maven modules of the main project pom.xml config.

The jococo coverage reports are generated appropriately in each sub-module’s respective target directory and produce a file named jacoco.exec. For example, there is a file at [root of project]/app/target/jacoco.exec. If I look in the file (yes, it’s binary but if you squint hard enough there’s some sense to be made of it) I can see the coverage information for my classes.

The problem is that sonar cannot seem to ingest the jacoco.exec file from a child module.

When enabling the debug logs (-X argument to maven) I see this in my build output:

[INFO] 16:24:33.859 Sensor Groovy JaCoCo Coverage [groovy]
[INFO] 16:24:33.863 Analysing /tmp/workspace/Apps_sentinel-service_PR-47-K6IY34YRWVSHCRUSXNJFB2CZSZB2WILBQEL2UJV6SFCGMZQ5D3GQ/app/target/jacoco.exec
[INFO] 16:24:33.900 Analysing /tmp/workspace/Apps_sentinel-service_PR-47-K6IY34YRWVSHCRUSXNJFB2CZSZB2WILBQEL2UJV6SFCGMZQ5D3GQ/app/target/sonar/jacoco-overall.exec
[WARNING] 16:24:33.958 File not found: com/optum/cirrus/isl/sentinel/controller/handler/
[WARNING] 16:24:33.958 File not found: com/optum/cirrus/isl/sentinel/service/v1/
[WARNING] 16:24:33.959 File not found: com/optum/cirrus/isl/sentinel/service/v1/impl/
[WARNING] 16:24:33.959 File not found: com/optum/cirrus/isl/sentinel/service/v1/impl/
[WARNING] 16:24:33.959 File not found: com/optum/cirrus/isl/sentinel/config/
[WARNING] 16:24:33.960 File not found: com/optum/cirrus/isl/sentinel/exception/
[WARNING] 16:24:33.960 File not found: com/optum/cirrus/isl/sentinel/service/v1/
[WARNING] 16:24:33.961 File not found: com/optum/cirrus/isl/sentinel/service/v1/
[WARNING] 16:24:33.961 File not found: com/optum/cirrus/isl/sentinel/controller/v1/
[WARNING] 16:24:33.961 File not found: com/optum/cirrus/isl/sentinel/service/v1/impl/
[WARNING] 16:24:33.962 File not found: com/optum/cirrus/isl/sentinel/controller/v1/
[WARNING] 16:24:33.962 File not found: com/optum/cirrus/isl/sentinel/
[WARNING] 16:24:33.962 File not found: com/optum/cirrus/isl/sentinel/health/
[WARNING] 16:24:33.963 Coverage information was not collected. Perhaps you forget to include debug information into compiled classes?
[INFO] 16:24:33.963 Sensor Groovy JaCoCo Coverage [groovy] (done) | time=104ms

I’ve searched the internet for this and found the general theme suggesting use of the jacoco report-aggregate goal (example: It seems odd to me that I should have to do extra steps to produce a separate aggregate jacoco report just to satisfy sonar when the sonar-maven-plugin is already traversing each maven sub-module and can locate its respective jacoco.exec file. Thus, I’m hoping someone can suggest a better solution here.

So far as I can tell, it looks like a bug or missing feature in the sonar-maven-plugin to me. Hopefully it’s just a misconfiguration on my part but I look forward to your replies!

Hey there.

  • Currently, you’re trying to import the JaCoCo report via the community-supported pmayweg/sonar-groovy plugin. This seems to accept .exec reports, but for any help you’ll need to reach out to the maintainer.
  • Generically, it is possible to import JaCoCo XML reports (see the documentation on Test Coverage & Execution. .exec reports are not supported. The best guide for doing this (producing the XML report(s) and passing them to the scanner) can be found here:

This addresses my issue. Thanks, @Colin for the details!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.