gpt4 book ai didi

java - Cobertura 排除了不在多模块 Maven 3 项目中工作的情况

转载 作者:行者123 更新时间:2023-12-02 05:45:45 25 4
gpt4 key购买 nike

我有一个多模块 Maven 3 项目。我们使用 Cobertura 作为代码覆盖率工具,但排除标签不起作用。我们从另一个团队继承的包中得到了一些糟糕的测试,但需要使用。

结构如下:

<module1>
.../com/aaaa/...
<module2>
.../com/aaaa/...
<module3>
.../com/aaaa/...
...
<moduleN>
packages with .../com/xx/... WE WANT TO EXCLUDE
pacakges with .../com/aaaa/... WE WANT TO STILL INCLUDE
parent-pom.xml

我们的父 POM 配置如下:

<build>
...
<plugins>
<other plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<aggregate>true</aggregate>
<outputDirectory>coverageReports</outputDirectory>
<instrumentation>
<excludes>
<exclude>**/com/xx/**/*</exclude>
</excludes>
</instrumentation>
/configuration>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<aggregate>true</aggregate>
<outputDirectory>coverageReports</outputDirectory>
</configuration>
</plugin>
</plugins>
</reporting>

我尝试了很多不同的配置,包括:

  1. 也排除 test/com/xx 文件
  2. 添加要忽略的排除模式
  3. 在报告和构建部分中设置排除
  4. 排除文件模式的多种排列,包括更加隐式

有什么想法吗?我让其他一些构建工程师查看了我的各种 POM 配置,它似乎总是有效,但我们从未获得准确的报告。

最佳答案

将排除配置放入要排除的 moduleN 的 pom.xml 文件中:

  <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<instrumentation>
<excludes>
<exclude>com/aaa/**/*.class</exclude>
<exclude>com/xxx/**/*.class</exclude>
</excludes>
</instrumentation>
</configuration>
</plugin>

关于java - Cobertura 排除了不在多模块 Maven 3 项目中工作的情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24087337/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com