# Java Project with multi modules

**URL:** <https://community.sonarsource.com/t/java-project-with-multi-modules/67705>\
**Category:** SonarQube Cloud\
**Tags:** multi-module, maven, sonarqube, java, coverage\
**Created:** [July 8, 2022, 11:59am UTC](https://community.sonarsource.com/t/java-project-with-multi-modules/67705 "2022-07-08T11:59:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rtiou](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/rtiou/32/35037_2.png) [@rtiou](https://community.sonarsource.com/u/rtiou)\
**Post date:** [July 8, 2022, 11:59am UTC](https://community.sonarsource.com/t/java-project-with-multi-modules/67705/1 "2022-07-08T11:59:06Z")

</div>

Tech Stack:

- JDK 17;
- Spring Boot 2.6.6
- Maven 3.8.5
- Gitlab Enterprise Edition 14.10.0-ee

My Java project is using multiple modules, I followed this guide [here](https://community.sonarsource.com/t/coverage-test-data-importing-jacoco-coverage-report-in-xml-format/12151).  
You can see here how my project is organized:  
 ![Screenshot 2022-07-08 at 13.33.43](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/0/4/048c21df16554b5845b62a348687d199f44e6572.png)

Into the main pom.xml file I added it:

```auto
<build>
    <plugins>
        <plugin>
            <artifactId>jacoco-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
            </executions>
            <groupId>org.jacoco</groupId>
            <version>0.8.8</version>
        </plugin>
    </plugins>
</build>

```

In the report module I added it:

```auto
<build>
    <plugins>
        <plugin>
            <artifactId>jacoco-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>report-aggregate</goal>
                    </goals>
                    <id>report-aggregate</id>
                    <phase>verify</phase>
                </execution>
            </executions>
            <groupId>org.jacoco</groupId>
            <version>0.8.8</version>
        </plugin>
    </plugins>
 </build>

```

The report module has the responsibility to aggregate the report just this.

When I ran `./mvnw clean verify` and check under the `report/target/site/jacoco-aggregate` folder, I am able to check the correct report for the 3 modules:

 ![Screenshot 2022-07-08 at 13.47.09](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/e/1/e194508df8704d354c97609f93b85a1fa0f72c10.png)

In the main pom.xml file I added this property:

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

```

But when I ran the pipeline into Gitlab and when I check it into SonarQube, I can see the coverage only for one module (data module):

 ![Screenshot 2022-07-08 at 13.55.00](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/b/7/b79254b0236ab2d8242d0354930894ddfed8c6b9.png)

I already checked the Gitlab log and I saw that Jacoco plugin was able to find the report;

```auto
[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=59ms

```

Do I miss some configuration to be able to reach my goal to see the coverage for all modules?

---

<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:** [July 8, 2022, 5:21pm UTC](https://community.sonarsource.com/t/java-project-with-multi-modules/67705/2 "2022-07-08T17:21:05Z")

</div>

Hi,

Welcome to the community!

You shouldn’t need to configure the location of your JaCoCo reports; they should be picked up automatically. Can you comment that section out of your pom & try again?

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![rtiou](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/rtiou/32/35037_2.png) [@rtiou](https://community.sonarsource.com/u/rtiou)\
**Post date:** [July 8, 2022, 10:05pm UTC](https://community.sonarsource.com/t/java-project-with-multi-modules/67705/3 "2022-07-08T22:05:58Z")

</div>

Hi G Ann Campbell, thank you for your suggestion.

I applied it and I got it:

 ![Screenshot 2022-07-08 at 23.57.19](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/b/3/b39a41bc7ac64aac0aa50d6199800face763efc8.png)

I checked the logs (GitLab) and I found it:

```auto
[INFO] Sensor JaCoCo XML Report Importer [jacoco]
[INFO] 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
[INFO] No report imported, no coverage information will be imported by JaCoCo XML Report Importer
[INFO] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms

```

Sincerely waiting for your reply.

---

<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:** [July 11, 2022, 2:26pm UTC](https://community.sonarsource.com/t/java-project-with-multi-modules/67705/4 "2022-07-11T14:26:06Z")

</div>

Hi,

Sorry. I took a look at the guide you referred to and it talks about setting your report property at the module level. So not only was I wrong about not needing to set it once, you need to set it multiple times. So not in the main pom, but in each module pom.

&nbsp;  
HTH,  
Ann

---

<div class="post-metadata">

**Author:** ![rtiou](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/rtiou/32/35037_2.png) [@rtiou](https://community.sonarsource.com/u/rtiou)\
**Post date:** [July 11, 2022, 4:07pm UTC](https://community.sonarsource.com/t/java-project-with-multi-modules/67705/5 "2022-07-11T16:07:12Z")

</div>

Hi, G Ann Campbell

I have already removed the `sonar.coverage.jacoco.xmlReportPaths` from the main pom.xml file and added this property into the API, data, and bootstrap, but it is still the same behavior.

Kind regards,

---

<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:** [July 11, 2022, 4:10pm UTC](https://community.sonarsource.com/t/java-project-with-multi-modules/67705/6 "2022-07-11T16:10:54Z")

</div>

Hi,

You’ve added it to the module poms and are still getting an error? Can you provide those analysis logs?

&nbsp;  
Ann
