Coverage at 0% in SonarQube (Java JaCoCo aggregated report in XML format)

Dear Sonar Community,

After looking on your site/google/StackOverFlow and multiple tries, I still cannot figure what’s happen.

I have a big Java nested multi-module Maven project. Build and tests are fine.
JaCoCo generate a unique jacoco.xml, allong other extention. If I open index.html, I get what I like to see in SonarQube

Versions

  • Maven = 3.5.3
  • Java = 11
  • SonarQube = Community Edition Version 9.9.2 (build 77730)
  • Sonar-maven-plugin = 3.10.0.2594
  • Jacoco-maven-plugin = 0.8.11
  • JaCoCo XML report importer = 1.3.0 (build 1538)
    (fetched from sonarqube.my-company.com/api/plugins/installed.
    (filename = sonar-jacoco-plugin-1.3.0.1538.jar)

Logs

  • Maven command
mvn -Dsonar.coverage.jacoco.xmlReportPaths=${WORKSPACE}/aggregate-report/target/site/jacoco-aggregate/jacoco.xml -sonar:sonar
  • Scanner output (for each modules)
...
[INFO] 17:05:51.144 Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
[DEBUG] 17:05:51.145 Reading report '/home/jenkins/workspace/nucleus-pipline/aggregate-report/target/site/jacoco-aggregate/jacoco.xml'
[INFO] 17:05:51.172 Sensor JaCoCo XML Report Importer [jacoco] (done) | time=28ms
...

Maven structure

  • root project
    • nucleus (pom)
      • backend (pom)
        • model-backend (jar)
        • system-backend (jar)
        • modules (pom)
          • sample-module (jar)
          • many others…
      • rest
      • many others…
    • aggregate-report (pom)

Do you have an idea?
Or do you need more logs or informations?

Thanks in advance

Hi,

Welcome to the community!

Can you provide the full analysis log, please?

 
Thx,
Ann

Hello Ann,

Here you have it. I removed maven build part, to provide only Sonar logs.
SonarQube-nucleus.log (376.0 KB)

Best,
Camille

Hi Camille,

It looks like you’ve created an aggregate Maven report, as described in the docs…?

I see this in your logs:

[INFO] Indexing files of module 'adNucleus - JaCoCo aggregate report'
[INFO]   Base dir: /home/jenkins/workspace/nucleus_adNucleus-pipline_master/jacoco-aggregate-report
[INFO]   Source paths: .
[INFO]   Included sources: src/main/**, frontend/projects/**

But I also see a JaCoCo report being processed for each module.

I’m guessing this last step was overlooked:

Then, in the top level pom.xml you set sonar.coverage.jacoco.xmlReportPaths to this location:

<properties>/
  <sonar.coverage.jacoco.xmlReportPaths>
    ${project.basedir}/report-aggregate/target/site/
      jacoco-aggregate/jacoco.xml
  </sonar.coverage.jacoco.xmlReportPaths>
</properties>

Can you try that?

And if it fails, can you add -X to your analysis command line to generate debug logs, so we can see the details promised here:

[INFO] Sensor JaCoCo XML Report Importer [jacoco]
[INFO] Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
[INFO] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=125ms

 
Thx,
Ann

This step was indeed specified in SonarQube tutorial. Here you have log with setup explain in tuto :
nucleus-jacoco-sonar.log (6.7 MB)

It seems odd because ${project.basedir} reference current sub-module and not the common one for aggregation (log show no report found at this location).

So I used another maven variable to always fall back to same folder of aggregation report :

<properties>
    <sonar.coverage.jacoco.xmlReportPaths>
        ${maven.multiModuleProjectDirectory}/jacoco-aggregate-report/target/site/jacoco-aggregate/jacoco.xml
    </sonar.coverage.jacoco.xmlReportPaths>
</properties>

And here you have debug log with my setup (same aggregated report founded this time) :
nucleus-jacoco-sonar-custom.log (6.9 MB)

Here you have jacoco.xml, if that’s helping (added .log extension to be able to upload) :
jacoco.xml.log (1.7 MB)

Thanks for your time and investigations.
Camille

Hi Camille,

Where did you put the property? It should have gone in the root/parent pom.

So what was the result here?

 
Ann

Alas that’s the setup I used when I created this topic were I get 0.0% of coverage…

Hi,

I’m not sure what else to look at, so I’m going to flag this for more expert eyes.

 
Ann

1 Like

Ahhh! Something working!

image

But only when I build releases. Coverage come back to 0.0 for SNAPSHOT…
I going to cross check differences between release and snapshot builds and come back to you.

Finger crossed that is ‘only’ a bug on SNAPSHOT build!

1 Like

After checking those build scripts…issue came from there.

I’m so sorry to have waste your time only to hold my hand…
Big thanks

Have great Christmas holiday…one week to hold! :slight_smile:
Best,
Camille

1 Like

I just want to add my two cents on this issue.

  • what Camille Dell Ava did does fix the issue (meaning the definition of the sonar.coverage.jacoco.xmlReportPaths using maven.multiModuleProjectDirectory)
  • the way the tutorial defines it does not work (meaning with the usage of project.basedir property, the reasoning is that which was previously mentioned of it taking the value of each individual sub-module, causing the other reports to be used instead of the aggregate one

    It seems odd because ${project.basedir} reference current sub-module and not the common one for aggregation (log show no report found at this location).

  • I tried finding more info about maven.multiModuleProjectDirectory and I found this SO Answer and it seams using it might be dis-encouraged and may cause the project to break on future maven versions

What I would like to get out of this comment is an enhancement on the configuration described the tutorial to make sure we get a consistent set up

Thanks in advance

Hi @Ordiel,

Welcome to the community!

What tutorial are you referring to?

 
Thx,
Ann