故障安全错误:使用阴影插件时“清单主要属性的签名文件摘要无效”

Lud*_*wik 3 jar maven maven-failsafe-plugin maven-shade-plugin

在 maven 中使用 shade-plugin 并稍后尝试使用 failsafe-plugin 运行集成测试时,当故障安全即将运行时,我收到以下错误,导致我的集成测试被跳过:

[ERROR] Invalid signature file digest for Manifest main attributes
Run Code Online (Sandbox Code Playgroud)

此错误似乎是由依赖项中的签名 jar 引起的。这个答案建议使用依赖插件过滤掉签名,但它似乎对我不起作用。Shade-plugin 只是解压了所有的依赖,并没有解决问题。我怎样才能使这项工作?

Lud*_*wik 5

过滤掉签名似乎是正确的方法,但可以(也许应该)直接在 shade-plugin 中完成,而不需要任何其他插件。这在 shade-plugins 网站上隐含记录,在那里它讨论了工件过滤器。我确保我的 shade-plugin 执行包含以下过滤器,并且它有效:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <version>3.2.0</version>
  <configuration>
    <createDependencyReducedPom>false</createDependencyReducedPom>
  </configuration>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
        <goal>shade</goal>
      </goals>
      <configuration>
        <filters>
          <filter>
            <artifact>*:*</artifact>
            <excludes>
              <exclude>META-INF/*.SF</exclude>
              <exclude>META-INF/*.DSA</exclude>
              <exclude>META-INF/*.RSA</exclude>
            </excludes>
          </filter>
        </filters>
      </configuration>
    </execution>
  </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)