简体   繁体   English

如何使用maven-assembly-plugin从DependencySet中删除META-INF?

[英]How to remove META-INF from dependencySet using maven-assembly-plugin?

I am using maven-assembly-plugin to build my deployment package. 我正在使用maven-assembly-plugin构建我的部署包。 One of our dependencies Jar is bcprov-jdk15on.jar which is a signed JAR. 我们的依赖项Jar之一是bcprov-jdk15on.jar ,它是一个签名的JAR。 I am using Proguard Shrinking step on top of the maven-assembly-plugin. 我在maven-assembly-plugin顶部使用Proguard Shrinking步骤。 Proguard basically removes some classes from bcprov-jdk15on.jar which causes the JAR signature verification to fail when JVM load the class. Proguard基本上从bcprov-jdk15on.jar中删除了一些类,这会在JVM加载类时导致JAR签名验证失败。

I am getting this error stack trace 我正在获取此错误堆栈跟踪

java.lang.SecurityException: SHA-256 digest error for org/bouncycastle/tsp/TSPException.class
at sun.security.util.ManifestEntryVerifier.verify(ManifestEntryVerifier.java:223) ~[?:1.8.0_201]
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:243) ~[?:1.8.0_201]
at java.util.jar.JarVerifier.update(JarVerifier.java:230) ~[?:1.8.0_201]
at java.util.jar.JarVerifier$VerifierStream.read(JarVerifier.java:484) ~[?:1.8.0_201]
at sun.misc.Resource.getBytes(Resource.java:124) ~[?:1.8.0_201]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:463) ~[?:1.8.0_201]
at java.net.URLClassLoader.access$100(URLClassLoader.java:74) ~[?:1.8.0_201]
at java.net.URLClassLoader$1.run(URLClassLoader.java:369) ~[?:1.8.0_201]
at java.net.URLClassLoader$1.run(URLClassLoader.java:363) ~[?:1.8.0_201]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_201]
at java.net.URLClassLoader.findClass(URLClassLoader.java:362) ~[?:1.8.0_201]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_201]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_201]

I can simply use keep options on my Proguard configuration to make this work (no signature verification error). 我可以简单地在Proguard配置上使用keep选项来完成这项工作(无签名验证错误)。 However, since this JAR is pretty big in size (4MB), I want to actually use it against this particular bcprov-jdk15on.jar 但是,由于此JAR的大小非常大(4MB),因此我想针对特定的bcprov-jdk15on.jar实际使用它。

Is there a way to unsign a dependency jar using maven-assembly-plugin? 有没有办法使用maven-assembly-plugin unsign对依赖项jar的unsign

According to this , I need to simply remove the Manifest file and all the signature related files (.SF, .DSA)? 根据这个 ,我需要简单地删除清单文件和所有签名相关的文件(.SF,.DSA)? Is there a way to exclude META-INF folder from dependencySets using maven-assembly-plugin? 有没有一种方法可以使用maven-assembly-plugin将META-INF文件夹从dependencySets中排除?

Thank you. 谢谢。

This is not possible with the maven assembly plugin. 使用maven程序集插件是不可能的。

From the documentation: 从文档中:

If your project wants to package your artifact in an uber-jar, the assembly plugin provides only basic support . 如果您的项目想要将工件打包在uber-jar中, 则Assembly插件仅提供基本支持 For more control, use the Maven Shade Plugin. 要进行更多控制,请使用Maven Shade插件。

But if you don't want to use the shade plugin -- sorry, you're stuck. 但是,如果您不想使用阴影插件,那么抱歉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM