我一直在尝试从生成的覆盖率报告中删除某些文件。我尝试了以下事情:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<executions>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
<configuration>
<excludes>
<exclude>**/com/abc/def/**</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule >
<element>BUNDLE</element>
<limits>
<limit >
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.50</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
修改后的代码:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<configuration>
<excludes>
<exclude>**/com/abc/def/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule >
<element>BUNDLE</element>
<limits>
<limit >
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.50</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
也尝试过,
<configuration>
<rules>
<rule >
<element>BUNDLE</element>
<limits>
<limit >
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.50</minimum>
</limit>
</limits>
<excludes>
<exclude>com.abc.def.className</exclude>
</excludes>
</rule>
</rules>
</configuration>
我在尝试找到解决方案时提到的许多链接中的一些链接:
Maven Jacoco 配置 - 从报告中排除类/包不起作用 https://stackoverflow.com/questions/27799419/maven-jacoco-configuration-exclude-classes-packages-from-report-not-working/42809987
Jacoco如何正确排除包 https://stackoverflow.com/questions/50681294/jacoco-how-to-correctly-exclude-package
如何在子项目中添加更多 Jacoco 排除项? https://stackoverflow.com/questions/38085451/how-to-add-more-jacoco-exclusions-in-a-child-project
http://tdongsi.github.io/blog/2017/09/23/jacoco-in-maven-project/ http://tdongsi.github.io/blog/2017/09/23/jacoco-in-maven-project/
但每次我生成报告时,文件仍然显示在给定的模块中。