最佳答案
我有一个 maven 多模块项目,我使用 Jacoco-maven 的代码覆盖率报告。有些类不应该被报告,因为它们是 Spring 配置,我对它们不感兴趣。
我已经声明了 maven-jacoco 插件如下:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
<configuration>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
<exclude>some.package.*</exclude>
<exclude>**/*Config.*</exclude>
<exclude>**/*Dev.*</exclude>
<exclude>some/package/SomeClass.java</exclude>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
问题在于,当我执行 mvn clean verify
时,jacoco 仍然报告那些应该在 xml 配置指出的情况下被排除在外的类。我怎样才能正确地配置它?