Maven 2 忽略cobertura maven插件中特定类的报告生成
我一直在使用Cobertura插件来生成报告和检测(使用surefire)。 以下是我面临的问题: 我无法使插件忽略项目中特定类的报告生成 在pom.xml的相关摘录下面,我添加了ignore标记,但这只是忽略了被忽略类的插装 我希望根本不生成特定项目的报告 首先,由于我对Maven和Conberture的了解有限,我想知道是否可能,如果可能,那么我需要在pom.xml中做哪些更改 pom.xmlMaven 2 忽略cobertura maven插件中特定类的报告生成,maven-2,code-coverage,maven-plugin,instrumentation,cobertura,Maven 2,Code Coverage,Maven Plugin,Instrumentation,Cobertura,我一直在使用Cobertura插件来生成报告和检测(使用surefire)。 以下是我面临的问题: 我无法使插件忽略项目中特定类的报告生成 在pom.xml的相关摘录下面,我添加了ignore标记,但这只是忽略了被忽略类的插装 我希望根本不生成特定项目的报告 首先,由于我对Maven和Conberture的了解有限,我想知道是否可能,如果可能,那么我需要在pom.xml中做哪些更改 pom.xml <report> <!-- other plugins exist bu
<report>
<!-- other plugins exist but are not important to be listed here I guess -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>false</skipTests>
<systemProperties>
<property>
<name>net.sourceforge.cobertura.datafile</name>
<value>target/cobertura/cobertura.ser</value>
</property>
</systemProperties>
</configuration>
</plugin>
<!-- The following is the plugin for cobertura, which takes care of integration and report generation-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<check>
<branchRate>50</branchRate>
<lineRate>50</lineRate>
<haltOnFailure>true</haltOnFailure>
<totalBranchRate>50</totalBranchRate>
<totalLineRate>50</totalLineRate>
<packageLineRate>50</packageLineRate>
<packageBranchRate>50</packageBranchRate>
</check>
<instrumentation>
<ignores>
<ignore>deshaw.dportal.alert.*</ignore>
<ignore>deshaw.dportal.atc.*</ignore>
<ignore>deshaw.dportal.basket.*</ignore>
<ignore>deshaw.dportal.fcs.*</ignore>
<ignore>deshaw.dportal.event.*</ignore>
<ignore>deshaw.dportal.filings.*</ignore>
<ignore>deshaw.dportal.glg.*</ignore>
<ignore>deshaw.dportal.icp.*</ignore>
</ignores>
</instrumentation>
</configuration>
</plugin>
</report>
我在module/pom.xml中尝试了以下内容
<instrumentation>
<excludes>
<exclude>**/apps/*.*</exclude>
</excludes>
</instrumentation>
**/应用程序/**
我仍然会在警报和公司目录中生成报告
排除正则表达式可能不正确?使用排除i.o.忽略。
我就是这样从cobertura中排除特定类的:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.4</version>
<configuration>
<instrumentation>
<excludes>
<exclude>com/bnpp/ecom/**/*Test.class</exclude>
<exclude>com/lrc/web/WicketApplication.class</exclude>
<exclude>com/lrc/service/HeartBeatWebServiceMock.class</exclude>
</excludes>
</instrumentation>
</configuration>
org.codehaus.mojo
cobertura maven插件
2.4
com/bnpp/ecom/***Test.class
com/lrc/web/WicketApplication.class
com/lrc/service/HeartBeatWebServiceMock.class
格里茨,StijnCobertura maven插件在生成报告时不考虑排除和忽略,但在检测时却考虑到了这一点
已知错误报告于:您可以通过将
块从
块移动到
中的
块,将类从您的cobertura报告中排除我遇到了类似的问题,并找到了一个非常有用的教程:
解决方案与rdvdijk发布的答案非常接近。插件信息应该在构建部分和报告部分。但是排除信息应该放在pom的构建部分。在将cobertura maven插件版本从2.6更改为2.4(如Stjin geukens在上述评论中所述)后,我可以通过忽略项目中的*测试文件成功生成cobertura覆盖率报告。
请在下面找到完整的maven插件详细信息:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.4</version>
<configuration>
<instrumentation>
<excludes>
<exclude>com/services/impl/*Test.class</exclude>
<exclude>com/exceptions/*Test.class</exclude>
<exclude>com/services/*Test.class</exclude>
<exclude>com/utils/*Test.class</exclude>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
org.codehaus.mojo
cobertura maven插件
2.4
com/services/impl/*Test.class
com/exceptions/*Test.class
com/services/*Test.class
com/utils/*Test.class
包裹
科贝图拉
附言:我不确定2.6版本的插件有什么问题。我也尝试过。它似乎根本没有排除。更新我的帖子以包含我尝试过的更改。你尝试过指定插件的版本吗?没有。这会有什么不同吗?试试看,这是我看到的你的配置和我的配置之间的唯一区别,你的正则表达式似乎还可以。我深入研究了一下,了解到排除和插装只适用于插装,而不适用于报告生成。我在回答中发布了一个链接。我自己也在研究这个问题。这让人非常恼火,因为我得到了很多不容忽视的报道。有什么解决方法吗?到目前为止,我唯一可能的解决方法是,包括子POM中的插件,用于您希望生成报告的儿童。除此之外,没有其他可行的方法可以立即完成此操作。此错误最近已在cobertura maven pluginplz的2.5.2版中修复。请详细说明您在外部链接中发布的任何内容。您的链接现在已失效:(
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.4</version>
<configuration>
<instrumentation>
<excludes>
<exclude>com/services/impl/*Test.class</exclude>
<exclude>com/exceptions/*Test.class</exclude>
<exclude>com/services/*Test.class</exclude>
<exclude>com/utils/*Test.class</exclude>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>