1

I have a multi-module project like lets say below:

Project
|-- DataModule
|-- LogicModule
|-- ServiceClientModule

In this project the service client will just implement calls to any services I'm calling and DataModule will just be data classes. Currently jacoco considers all of these modules. Is there a way to exclude complete modules like DataModule or ServiceClientModule since there's no need for UTs in both those cases?

Ganesh
  • 109
  • 2
  • 9
  • possible duplicate of [Maven Jacoco Configuration - Exclude classes/packages from report not working](https://stackoverflow.com/questions/27799419/maven-jacoco-configuration-exclude-classes-packages-from-report-not-working) – Ahmed HENTETI Apr 15 '21 at 01:00
  • So in that I see option to exclude class/package but not module. My modules have several packages and it'll be cumbersome to maintain every time we add a new package to say DataModule to go add it to the config. So I'm looking for something to exclude whole modules or include only certain modules like sonar allows for example – Ganesh Apr 15 '21 at 01:07

2 Answers2

1

To generate a report for a multi-module Maven project, here is how it needs to be setup.

parent/
├── child1
├── child2
├── jacoco-reports    <-- Adds dependency for child1 and child2 modules
└── pom.xml

When you run the build to generate the aggregate report using the report-aggregate goal, the coverage report is generated in the jacoco-reports module for the entire project.

With this setup, you can pick and chose the modules for which the report is generated.

Here is my article for using jacoco-maven-plugin with multi-module Maven projects.

Code Journal
  • 161
  • 4
0

if you are using maven, you can add a profile in the root pom (where the modules are specified), where you specify the plugin in a plugin management section. in each module you want to run jacoco, you have to reference the plugin. it will generate the site folder only in the modules where you need the jacoco report.

Laura Liparulo
  • 2,849
  • 26
  • 27