从jacoco覆盖率报告中排除jar文件的类 [英] Exclude classes of jar files from jacoco coverage report

查看:262
本文介绍了从jacoco覆盖率报告中排除jar文件的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jacoco代码覆盖率报告还包括我使用下面的maven依赖项添加的系统路径jar"中的类

Jacoco code coverage report is also including classes from "system path jar" that I have added using below maven dependency

<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文件:

I tried to exclude the files of this jar from jacoco plugin like this :

            <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. 程序包中的文件不应在覆盖率报告中.

But the exclusion is not working. It is still showing the coverage report for the files contained in jar. As it is shown in image, the files in org.apacke. and org.clobus. package should not be there in the coverage report.

推荐答案

我找到了答案

 <exclude>**/lib/*</exclude>

以上排除排除了我的jar文件中具有system范围的类.

The above exclusion exclude the classes from my jar file with system scope.

这篇关于从jacoco覆盖率报告中排除jar文件的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆