我一直在尝试从生成的覆盖率报告中删除某些文件。我尝试了以下方法:
<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 Configuration - Exclude classes/packages from report not working
Jacoco how to correctly exclude package
How to add more Jacoco exclusions in a child project?
http://tdongsi.github.io/blog/2017/09/23/jacoco-in-maven-project/
但是,每次生成报告时,文件仍会显示在给定的模块中。