Maven和JaCoCo-如何从依赖项引入的报表中排除类?

问题描述 投票:0回答:1

我正在将JaCoCo添加到项目中,并且正在努力使其从子模块的报告中排除类(通过依赖关系引入)。这是我得到的错误:

Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.7.1:site (default-site):
Error generating jacoco-maven-plugin:0.8.4:report:
Error while creating report:
Error while analyzing ~/proj/submod/target/classes/mydep-jar-with-dependencies.jar@com/jlb/proj/pkg/MyClass.class. Can't add different class with same name: com/jlb/proj/pkg/MyClass

然后有问题的jar像这样被带到子模块中:

<dependencies>
  <dependency>
    <groupId>com.jlb.pkg</groupId>
    <artifactId>mydep</artifactId>
    <version>${revision}</version>
    <classifier>jar-with-dependencies</classifier>
    </dependency>
</dependencies>

jacoco报告是通过项目的整体父POM中的一个块生成的,但是我在这里在有问题的子模块中添加了一个替代,该替代应排除其抱怨的类(依赖项中的类的版本),但没有效果:

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco.version}</version>
        <reportSets>
          <reportSet>
            <reports>
              <report>report</report>
              <report>report-integration</report>
            </reports>
          </reportSet>
        </reportSets>
        <configuration>
            <excludes>
                <exclude>**/com/jlb/proj/pkg/MyClass.class</exclude>
            </excludes>
        </configuration>
      </plugin>
    </plugins>
  </reporting>

因此,如何从报告中排除违规类别?

java maven jacoco
1个回答
0
投票

请尝试

 <exclude>**/lib/*</exclude>
© www.soinside.com 2019 - 2024. All rights reserved.