6

We have recently upgraded to SonarCube 4.3.2. In he previous version (don't remember what it was) it was possible to select Jacoco as code coverage analyser and to define the excludes in Maven as a simple property;

e.g.

<properties>
    <sonar.jacoco.excludes>*/cache/*:*/*Application.java</sonar.jacoco.excludes>
</properties>

With this version of SonarCube the option to select Jacoco is no longer there so I am trying to get it working in another way. Many many many posts about this subject but none of them solved my problem. I managed to exclude classes but these then show as 0% in SonarCube (and bring down the total coverage). Excluding through above property no longer seems to work.

In my pom I have added following plugin:

<plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.6.0.201210061924</version>
        <configuration>
            <excludes>
                <exclude>**/SonarTest*</exclude>
            </excludes>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>prepare-agent</goal>
                </goals>
            </execution>
            <execution>
                <id>report</id>
                <phase>prepare-package</phase>
                <goals>
                    <goal>report</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

The configuration seems ok because in the Jacoco report the class is completely excluded. SonarTest is partially tested but with this config it shows as 0% in Sonar so it seems the exclusion is working to some extend. How can I inform Sonar that these excluded classes should be completely ignored coverage-wise.

Stijn Geukens
  • 15,454
  • 8
  • 66
  • 101

0 Answers0