【问题标题】:Cobertura excludes not working in multi-module Maven 3 projectCobertura 不包括不在多模块 Maven 3 项目中工作
【发布时间】:2014-06-06 17:15:33
【问题描述】:

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

结构如下:

<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 配置,它似乎总是有效的,但我们从来没有得到准确的报告。

【问题讨论】:

    标签: java maven-3 multi-module maven-cobertura-plugin


    【解决方案1】:

    将排除配置放入要排除的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>
    

    【讨论】:

    • 我面临着类似的问题。但即使在添加排除和忽略之后,我仍然在 cobertura 的报告中找到排除的类。还尝试在 pom.xml 的 部分使用相同的插件,但没有成功。请帮忙。
    猜你喜欢
    • 2010-11-28
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    • 2011-04-15
    • 2013-08-08
    • 2021-04-02
    • 2021-05-28
    • 1970-01-01
    相关资源
    最近更新 更多