Julien,
Thanks, it worked.
To make it work, I added to the pom.xml file all the exclusions in the same line of the "sonar.coverage.exclusions" property with the paths starting from the app's root and using the .JAVA extension.
I also added the files to the Jacoco plugin excludes section, with each path starting from the beginning of the package and using the .CLASS extension.
Using the maven command line (mvn clean verify sonar:sonar -Dsonar.coverage.exclusions=...) also worked but I prefer to add such options to the pom file for cleanness sake.
As of a suggestion, it would be nice if you could make it possible to add the exclusions in multiple lines, separated by commas. I tried that way and it only recognized the first line and the first comma.
See the full configuration below.
<properties>
...
<sonar.coverage.exclusions> <!-- the members of the following list should be in the same line -->
src/main/java/nz/co/company/project/application/dto/*.java,src/main/java/nz/co/company/project/application/exception/*.java
</sonar.coverage.exclusions>
...
</properties>
...
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<configuration>
<excludes>
<exclude>nz/co/company/project/application/dto/*.class</exclude>
<exclude>nz/co/company/project/application/exception/*.class</exclude>
</excludes>
<destFile>${sonar.jacoco.reportPath}</destFile>
</configuration>
<executions>
...
</executions>
</plugin>
...
Regards,
Rob.