Jacoco代码覆盖率报告还包括我使用maven依赖项下添加的“系统路径jar”中的类
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.2.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/axis-1.2.1.jar</systemPath>
</dependency>
我试图从jacoco插件中排除这个jar文件,如下所示:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
<configuration>
<excludes>
<exclude>**/org/apache/**/*</exclude>
<exclude>**/org/globus/**/*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>
<!-- Sets the name of the property containing the settings for JaCoCo
runtime agent. -->
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>${project.build.directory}/coverage-reports/jacoco.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
但排除不起作用。它仍然显示jar中包含的文件的覆盖率报告。 如图所示, org.apacke。 和 org.clobus。 包中的文件不应该在报道报告中。
答案 0 :(得分:5)
我找到了答案
<exclude>**/lib/*</exclude>
上述排除将我的jar文件中的类排除在system
范围内。