Exclude child maven modules for sonar coverage | Scala | Maven

Hello, I am creating a multimodule maven project and I am applying the step of coverage with scoverage-maven-plugin. However, some of the sub modules are implemented to skip the coverage, since don’t have source files to analyse.
Is there any way to exclude these modules from skipping the sonar coverage analysis?

I tried with sonar.coverage.exclusions, but that will only exclude the files but still makes all the steps of sonar scanner for all the modules.

Some project information

  • ALM used: GitHub
  • CI system used: GitHub Actions
  • Scala/Java with Maven

Thank you :slight_smile:

Hey there.

I’m having a bit of a hard time understanding precisely what you’re trying to accomplish. Maybe you can share some configuration / logs (specifically that show the undesired behavior)? :slight_smile:

It’s not a really big issue. But I am avoiding the warning logs :sweat_smile:
Here’s the log:

[INFO] Sensor Scoverage sensor for Scala coverage [sonarscala]
[WARNING] Unable to import Scoverage report file(s):
- PATH_MODULE_CONFIDENTIAL/target/scoverage.xml
The report file(s) can not be found. Check that the property ‘sonar.scala.coverage.reportPaths’ is correctly configured.

The coverage is being analysed for the modules that have the xml file, but I wanted to exclude those which don’t have just to avoid these warnings

Ah, I understand a bit better.

What’s happening is that by configuring sonar.scala.coverage.reportPaths in your top-level pom.xml, as an analysis parameter (mvn sonar:sonar -Dsonar.scala.coverage.reportPaths=scoverage.xml), or in the UI, the analysis parameter is applied to each submodule.

One way to workaround this would be to define sonar.scala.coverage.reportPaths in the pom.xml only of the relevant sub-modules, and make sure you aren’t defining it at the project-level.

1 Like

Oh, that makes so much sense!
Also, it worked :slight_smile: Thank you very much!!

1 Like

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