I am writing generic code for an application which should support multiple country-specific changes, e.g, Brazil and France.
There are some java classes in Brazil which are not required for France. Hence for running the sonarqube, I need to exclude those files for sonar coverage. Also, I would need to exclude dtos, util classes.
We usually exclude the coverage for the classes in the pom file using tag. But I would be requiring to exclude the files with mvn clean install command.
Traditional approach:
But I want to exclude the java classes in the terminal like below:
C:\Projects\web-application>mvn clean install -Dspring.profiles.active=dev -Dspring.profiles.country=brazil -Dsonar.coverage.exclusions=**/pom.xml,**/domain/dtos/**/*,**/domain/models/**/*,**/services/someClass.java
Sonarqube runs but unable to exclude the files.
I'm assuming You are using In Your params:
-Dsonar.coverage.exclusions=**/pom.xml,**/domain/dtos/**/*,**/domain/models/**/*,**/services/someClass.java
You are mixing path and file exclusions which can cause problems, as mentioned here by Sonar Dev - https://community.sonarsource.com/t/sonar-coverage-exclusions-not-excluding-too-much/31276/4
This should work:
-Dsonar.coverage.exclusions=**/pom.xml,**/domain/dtos/**/*.*,**/domain/models/**/*.*,**/services/someClass.java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With