2

我有以下jacoco-maven-plugin配置:

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco.version}</version>
        <configuration>
          <excludes>
            <exclude>**/Header*.java</exclude>
          </excludes>
        </configuration>
        <executions>
          <execution>
            <id>prepare-agent</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

这应该从代码覆盖率报告中排除所有生成的以 . 开头的 java 文件Header。不幸的是,我仍然在我的代码覆盖率报告中看到这些类,coveralls-maven-plugin当我调用coveralls:report. 我打电话时得到的错误coveralls:report是:

: No source found for HeaderMyClass.java ->

这让我觉得 JaCoCo 覆盖率报告仍然包含自动生成的此类的数据。

4

2 回答 2

2

report只需在 jacoco-maven-plugin 配置中为目标添加排除项

<execution>
  <id>coverage-report</id>
  <phase>post-integration-test</phase>
  <goals>
    <goal>report</goal>
  </goals>
  <configuration>
    <excludes>
      <exclude>**/*Dto.class</exclude>
      <exclude>com/foo/config/*</exclude>
    </excludes>
  </configuration>
</execution>
于 2020-01-20T13:37:49.563 回答
1

将模式更改为:

  <excludes>
    <exclude>**/Header*.*</exclude>
  </excludes>

成功了

于 2019-06-29T15:02:22.833 回答