# Java coverage reported as 0%

**URL:** <https://community.sonarsource.com/t/java-coverage-reported-as-0/138032>\
**Category:** SonarQube Cloud\
**Tags:** jacoco, java, coverage\
**Created:** [March 31, 2025, 2:23pm UTC](https://community.sonarsource.com/t/java-coverage-reported-as-0/138032 "2025-03-31T14:23:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmtn](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mmtn](https://community.sonarsource.com/u/mmtn)\
**Post date:** [March 31, 2025, 2:23pm UTC](https://community.sonarsource.com/t/java-coverage-reported-as-0/138032/1 "2025-03-31T14:23:07Z")

</div>

Hi all;

I can see this is asked multiple times but I wasn’t able to find a solution to this still. I followed the guideline [here](https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/scanners/sonarscanner-for-maven/) and set up the project accordingly but coverage somehow is not being reported.

### Some Basic Details:

I checked coverage in my local and its properly generated:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/d/0/d0ceea3f11f97bebb3ddb4287b3bfa47d1174dec.png)

#### Basic Project Info:

- Language: Java 21 with maven
- CI System Used: GitHub actions
- SonarQubeCloud (aka sonarcloud)

## Details or Troubleshooting:

#### 1) pom.xml

- related properties:

- jacoco plugin config:

- related dependencies:

#### 2) dev-ci.yml file

```yml
jobs:
  run:
env:
  SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  SONAR_MAVEN_PLUGIN_VERSION: 5.1.0.4751
runs-on: ubuntu-22.04
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          token: ${{ secrets.GH_TOKEN }}
          fetch-depth: 0
      - name: Set up JDK 21
        uses: actions/setup-java@v4
        with:
          java-version: '21.0.1'
          distribution: 'temurin'
      - name: Cache SonarQube packages
        uses: actions/cache@v4
        with:
          path: ~/.sonar/cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar
      - name: Cache Maven dependencies
        uses: actions/cache@v4
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-maven-
      - name: Build test and sonar scan
        run: |
            mvn -s .github/setting.xml clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:${{env.SONAR_MAVEN_PLUGIN_VERSION}}:sonar -Dsonar.verbose=true

```

Finally attaching the verbose logs of sonar:

```plaintext
[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=62ms

```

[sonar\_logs.txt](https://community.sonarsource.com/uploads/short-url/nTl8LdzTZDCdazXQhwsTLnP0GGn.txt) (17.7 KB)

any help is appreciated, Thank You in advance!

---

<div class="post-metadata">

**Author:** ![mmtn](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mmtn](https://community.sonarsource.com/u/mmtn)\
**Post date:** [March 31, 2025, 2:36pm UTC](https://community.sonarsource.com/t/java-coverage-reported-as-0/138032/2 "2025-03-31T14:36:28Z")

</div>

additional info: it’s a singe module project.  
and here is the latest analysis result:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/0/8/08dbfbc2b5401966c2479b5582791ffa578ae93d.png)

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [April 1, 2025, 1:25pm UTC](https://community.sonarsource.com/t/java-coverage-reported-as-0/138032/3 "2025-04-01T13:25:00Z")

</div>

Hi,

You’ve got `sonar.verbose` set to `true` in two different places, but it doesn’t seem to be picked up:

> [@mmtn](#):
>
> `<sonar.verbose>true</sonar.verbose>`

> [@mmtn](#):
>
> ` mvn -s .github/setting.xml clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:${{env.SONAR_MAVEN_PLUGIN_VERSION}}:sonar -Dsonar.verbose=true`

It makes me wonder where the analysis command is actually coming from. Can you dig into that & try to get verbosity actually turned on? As you can see, without it there’s not much in the log.

That said, this is a pull request analysis, and pull request analysis only reports on what was changed in the PR. So… what was changed in the PR? Based on your last screenshot, there don’t seem to have been any actual code changes? That would track with having 0% coverage: 0 code =\> 0 coverage.

On a side note, I’m compelled to comment on your properties:

> [@mmtn](#):
>
> ```auto
> <sonar.language>java</sonar.language>
> <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
> 
> ```

These do nothing.

> [@mmtn](#):
>
> ```auto
> <sonar.sources>src/main/java</sonar.sources>
> <sonar.tests>src/test/java</sonar.tests>
> <sonar.java.binaries>target/classes</sonar.java.binaries>
> 
> ```

These are the standard Maven locations, so there’s no reason to specify them explicitly.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![mmtn](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mmtn](https://community.sonarsource.com/u/mmtn)\
**Post date:** [April 2, 2025, 8:34am UTC](https://community.sonarsource.com/t/java-coverage-reported-as-0/138032/4 "2025-04-02T08:34:36Z")

</div>

Hi Ann, thank you for your response.

I fixed the issue by moving all the commands to mvn arguments instead of providing them as properties in pom.xml. Sonar is failing to recognize them from the pom.xml. It seems like you guys have an issue here, i suggest to take a look at this deeper.

> You’ve got `sonar.verbose` set to `true` in two different places, but it doesn’t seem to be picked up  
> …  
> Can you dig into that & try to get verbosity actually turned on?

That is true but is there another way to turn it on apart from what i did? I can’t see any other option even if i dig. Please provide it if you know so.

> That said, this is a pull request analysis

I thought the same and I merged the PR to the main branch but there is still no coverage was being reported…until i moved everything to cmd line arguments instead of using pom.xml

> These do nothing.

Then there should be no problem keeping them but removed everything just in case.

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [April 2, 2025, 11:45am UTC](https://community.sonarsource.com/t/java-coverage-reported-as-0/138032/5 "2025-04-02T11:45:19Z")

</div>

Hi,

> [@mmtn](#):
>
> moved everything to cmd line arguments instead of using pom.xml

Where, exactly, in the pom did you put the properties? They need to be in the main `<properties>` section.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![mmtn](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mmtn](https://community.sonarsource.com/u/mmtn)\
**Post date:** [April 2, 2025, 12:22pm UTC](https://community.sonarsource.com/t/java-coverage-reported-as-0/138032/6 "2025-04-02T12:22:06Z")

</div>

they were exactly under the main `<properties>` tag

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/c/b/cb6540f91ed53be351cf197a2ea75b54f90edc70.png)  
now they are in run commands that comes after mvn clean verify…-Dsonar…

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [April 9, 2025, 12:22pm UTC](https://community.sonarsource.com/t/java-coverage-reported-as-0/138032/7 "2025-04-09T12:22:42Z")

</div>

Closed on April 9, 2025, 12:22pm UTC

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