排除的类别仍计入总覆盖范围结果

Sti*_*ens 5 maven jenkins jacoco sonarqube jacoco-maven-plugin

我们最近已升级到SonarCube 4.3.2。在以前的版本中(不记得它是什么),可以选择Jacoco作为代码覆盖率分析器,并可以将Maven中的排除项定义为简单属性。

例如

<properties>
    <sonar.jacoco.excludes>*/cache/*:*/*Application.java</sonar.jacoco.excludes>
</properties>
Run Code Online (Sandbox Code Playgroud)

在此版本的SonarCube中,不再存在选择Jacoco的选项,因此我试图以其他方式使其工作。关于这个主题的很多很多帖子,但是都没有解决我的问题。我设法排除了类,但这些类在SonarCube中显示为0%(并降低了总覆盖率)。通过上述财产排除似乎不再起作用。

在我的pom中,我添加了以下插件:

<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>
Run Code Online (Sandbox Code Playgroud)

配置似乎可以,因为在Jacoco报告中完全排除了该类。SonarTest已进行了部分测试,但使用此配置,Sonar在Sonar中显示为0%,因此似乎排除项在某种程度上起作用。我如何通知Sonar这些被排除的类在覆盖范围内应该被完全忽略。