jacoco coverage for sub-submodule

498 views
Skip to first unread message

Julien Gerber

unread,
Jun 10, 2022, 10:00:54 AM6/10/22
to JaCoCo and EclEmma Users
Hi everyone.
I come here with an issue for which I couldn't find anything yet.

I have a maven multi-module project for with I can succesfuly push into sonarqube the coverage. But one of these module has a pom packaging with submodules and I cannot get the coverage for this one.

What I'm doing is quite complex so I'll try to explain as much as I can

First, here is the structure I have:
- Parent
-- Module 1
-- Module 2
-- Module 3
--- Module 3.1
--- Module 3.2
-- Coverage-report

For all these modules, I have a combination of unit and integration tests that i managed to merge, aggregate and push under sonarqube

The parent pom contains all these step to run with surefire and failsafe the tests. it also have the <goal>merge</goal> to merge in one .exec file the results of unit and integration tests.
Then the report-coverage pom has the dependencies to all modules builded and makes the report-aggregate goal with all merged.exec files

As I said, module 3 as a packaging as pom and is also declared like this as a dependency in the coverage-report.

I see the merged.exec and the results in target repo from module 3.1 and 3.2, but no consolidated coverage in the aggregation for module 3.
I tried to declare the sub module in the coverage but then I have the submodule coverage but sonarqube cannot understand it.

Does this kind of structure have a solution?
Thank you very much for the help


Julien Gerber

unread,
Jun 10, 2022, 11:27:01 AM6/10/22
to JaCoCo and EclEmma Users
Okay so I finally found a way to do it :)
For people that would find a way to achieve this:
In my Coverage-report.xml I added these dependencies:
<dependency>
<groupId>my.group</groupId>
<artifactId>Module-3</artifactId>
<version>${project.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>my.group</groupId>
<artifactId>Module-3-1</artifactId>
<version>${project.version}</version>
</dependency>

And then in the Parent pom xml, here comes the magic, the properties sonar.coverage.jacoco.xmlReportPaths is in fact a list so before I had:
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/../coverage-report/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>

And in bamboo logs pushing to sonar I saw that it wasn't able to find the report for ...../Module-31/../coverage-report/......
So I added a second path
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/../coverage-report/target/site/jacoco-aggregate/jacoco.xml,
${project.basedir}/../../coverage-report/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>

good luck for the ones that would like to do the same :)

Marc Hoffmann

unread,
Jun 11, 2022, 4:04:36 AM6/11/22
to jac...@googlegroups.com
Thanks Julien for sharing this insight!

Regards,
-marc

> On 10. Jun 2022, at 16:00, Julien Gerber <jrm.g...@gmail.com> wrote:
>
> Coverage-report
Reply all
Reply to author
Forward
0 new messages