问题描述
在maven中使用shade-plugin并稍后尝试使用failsafe-plugin运行集成测试时,在将要运行failsafe时出现以下错误,导致我的集成测试被跳过:
[ERROR] Invalid signature file digest for Manifest main attributes
此错误似乎是由依赖项中的签名jar引起的。 This answer建议使用依赖插件来过滤签名,但是它似乎对我不起作用。阴影插件只是解压缩了所有依赖项,并没有解决问题。我该如何工作?
解决方法
过滤掉签名似乎是正确的方法,但是可以(也许应该)直接在阴影插件中完成,而无需任何其他插件。这是implicitly documented on shade-plugins website,其中讨论了工件过滤器。我确保我的阴影插件执行包括以下过滤器,并且可以正常工作:
<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>