问题
How can I exclude some META-INF files when building a bundled jar using the maven apache felix plugin?
Here's my felix config
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<!-- Embed all dependencies -->
<Embed-Transitive>true</Embed-Transitive>
<Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
</instructions>
</configuration>
</plugin>
I'm pulling in all transitive dependencies and embedding them because I want to create a single jar that I can add to my classpath.
When I try to run my jar though I get the exception
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
Following a post I found on SO, I manually deleted some META-INF/ files that appear to come from the bouncy files. I then recreated my jar file and it worked. Is there a way to do this automatically using the felix plugin?
Thanks
回答1:
It looks like the shade plugin makes this easy. So I switched to using the shade plugin rather than using the felix plugin. Here's my pom plugin config:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<!-- We need to exclude the signatures for any signed jars otherwise
we get an exception. -->
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
See http://goo.gl/dbwiiJ
来源:https://stackoverflow.com/questions/28292874/how-to-exclude-meta-inf-files-from-bundle