我试图从Jacoco覆盖中排除某些包和类,因为它们已被弃用。我尝试在Jacoco插件中添加exclude
,如下所示,但当我查看Jenkins上的Jenkins报告时,我看到所有这些类也没有覆盖,包括它们的行数
这是我的目录结构,用于存放我想忽略的内容。
com/dir1/dir2/dir3/dir4/dir5/XYZScreeningTask.java
com/dir1/dir2/dir3/dir4/dir6/dir7/XYZScreeningData.java
com/dir1/dir2/dir3/dir4/dir8/xyzscreening/BaseXYZFileProcessor.java
com/dir1/dir2/dir3/dir4/dir8/xyzscreening/XYZScreeningFileProcessor.java
com/dir1/dir2/dir3/dir4/dir8/abccmcactivity/AbcCMSActivityProcessor.java
下面是在plugins
下添加的模式<excludes>
<exclude>com/dir1/dir2/dir3/dir4/**/*xyz*/**</exclude>
<exclude>com/dir1/dir2/dir3/dir4/**/*XYZ*.*</exclude>
<exclude>com/dir1/dir2/dir3/dir4/**/*abc*/**</exclude>
<exclude>com/dir1/dir2/dir3/dir4/**/*Abc*.*</exclude>
</excludes>
这里是插件信息,其中排除已添加。
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<configuration>
<excludes>
<exclude>com/dir1/dir2/dir3/dir4/**/*xyz*/**</exclude>
<exclude>com/dir1/dir2/dir3/dir4/**/*XYZ*.*</exclude>
<exclude>com/dir1/dir2/dir3/dir4/**/*abc*/**</exclude>
<exclude>com/dir1/dir2/dir3/dir4/**/*Abc*.*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>instrument</id>
<phase>process-classes</phase>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>restore</id>
<phase>prepare-package</phase>
<goals>
<goal>restore-instrumented-classes</goal>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>pre-unit-test</id>
<phase>none</phase>
</execution>
<execution>
<id>post-unit-test</id>
<phase>none</phase>
</execution>
<execution>
<id>pre-integration-test</id>
<phase>none</phase>
</execution>
<execution>
<id>post-integration-test</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
就像Jacoco文档中说的
要从报告中排除的类文件列表。可以使用通配符(*和?)。如果未指定,则不排除任何内容。
您需要指定编译类的类路径。我没有看到你想要排除的文件和包中的模式,所以如果你想要排除特定的类。
<excludes>
<exclude>com/dir1/dir2/dir3/dir4/dir6/dir7/XYZScreeningData.class</exclude>
<exclude>com/dir1/dir2/dir3/dir4/dir8/xyzscreening/BaseXYZFileProcessor.class</exclude>
<exclude>com/dir1/dir2/dir3/dir4/dir8/xyzscreening/XYZScreeningFileProcessor.class</exclude>
<exclude>com/dir1/dir2/dir3/dir4/dir8/abccmcactivity/AbcCMSActivityProcessor.class</exclude>
</excludes>
然而,我们可以通过以下方式排除完整的包,
<exclude>com/dir1/**/*</exclude>
通配符的更多信息可以从这里和这里找到。说。
* matches zero or more characters
** matches zero or more directories
? matches a single character