Maven jacoco 排除不起作用
Maven jacoco excludes does not work
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<configuration>
<!-- remove haltOnFailure to purposely fail build once we recover coverage back to 70% -->
<haltOnFailure>false</haltOnFailure>
<rules>
<rule>
<element>CLASS</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.70</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.70</minimum>
</limit>
</limits>
<excludes>
<!-- exclude domain objects -->
<exclude>com/path/to/classes/**/*</exclude>
</excludes>
</rule>
</rules>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
<goal>report</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
</plugins>
预期行为: target/site/jacoco/index 的 HTML 报告。html 不包含 com/path/to/classes[= 的行12=]
实际行为: target/site/jacoco/index 处的 HTML 报告包含 com/path/to/classes 的一行,这导致了覆盖被报告为(在我的例子中)32%,证明这个包裹被包括在内而不应该是。
我一定是哪里做错了?
您可以在 configuration
的 excludes
节点
上完全排除来自 instrumentation/analysis/reports 的文件
<configuration>
<excludes>
<exclude>com/path/to/classes/**/*</exclude>
</excludes>
</configuration>
在 rule
节点上指定的排除忽略 类 仅针对该规则排除的
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<configuration>
<!-- remove haltOnFailure to purposely fail build once we recover coverage back to 70% -->
<haltOnFailure>false</haltOnFailure>
<rules>
<rule>
<element>CLASS</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.70</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.70</minimum>
</limit>
</limits>
<excludes>
<!-- exclude domain objects -->
<exclude>com/path/to/classes/**/*</exclude>
</excludes>
</rule>
</rules>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
<goal>report</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
</plugins>
预期行为: target/site/jacoco/index 的 HTML 报告。html 不包含 com/path/to/classes[= 的行12=]
实际行为: target/site/jacoco/index 处的 HTML 报告包含 com/path/to/classes 的一行,这导致了覆盖被报告为(在我的例子中)32%,证明这个包裹被包括在内而不应该是。
我一定是哪里做错了?
您可以在 configuration
的 excludes
节点
<configuration>
<excludes>
<exclude>com/path/to/classes/**/*</exclude>
</excludes>
</configuration>
在 rule
节点上指定的排除忽略 类 仅针对该规则排除的