3
Jacoco代碼覆蓋報告還包括「系統路徑罐子」,我用下面的Maven依賴添加類排除的jar文件類從jacoco覆蓋報告
<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插件是這樣的:
<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。包裹不應該在覆蓋率報告中。
我認爲排除模式只支持通配符的一些變化。例如。無論從前面:*/**測試*或最後:org/apache/* - 我認爲你的模式只應該是「org/apache/**/*」。另一種方法是使用includes,並且只包含你自己的包,因爲這可能是一個更短的列表。 – wemu