1

I'm trying to exclude some packages from the Jacoco coverage scan, but it's not working like how I would expect. Here's my Maven POM configuration for Jacoco:

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.0</version>
    <configuration>
        <excludes>
            <exclude>**/pojo/**/*</exclude>
        </excludes>
</configuration>
</plugin>

The behavior I'm experiencing is that the files are being set to 0% lines covered instead of reducing the total lines to cover, which is actually reducing my coverage percentage. So how do I correct this?

EDIT: A workaround for this issue is to remove the file entirely from SonarQube using sonar properties:

<sonar.exclusions>**/pojo/**/*</sonar.exclusions>

However, this is just a workaround since now I can't see code smells from those files (there probably aren't any since they are POJOs, but I like the sense of security of knowing for a fact there are no code smells).

George
  • 2,820
  • 4
  • 29
  • 56
  • where is your ...... ? – Stéphane GRILLON Oct 10 '18 at 20:03
  • 1
    Current explanation of your case is not different from existing answered questions about this - e.g. https://stackoverflow.com/a/50294239/244993 , https://stackoverflow.com/a/39446033/244993 , https://stackoverflow.com/a/28147991/244993 If it is different, then please make sure to add more details. And please make sure to read https://stackoverflow.com/help/mcve to provide enough details, including Minimal, Complete, and Verifiable example. – Godin Oct 10 '18 at 21:58

1 Answers1

1

Total lines of code in Sonar are not totally managed by Jacoco. You need to add this property to your pom.xml:

<properties>
    <sonar.coverage.exclusions>**/pojo/**/*</sonar.coverage.exclusions>
</properties>
Nicolas
  • 1,812
  • 3
  • 19
  • 43