如何从包中排除META-INF文件? [英] How to exclude META-INF files from bundle?

查看:408
本文介绍了如何从包中排除META-INF文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Maven Apache Felix插件构建捆绑的jar时,如何排除一些META-INF文件?

How can I exclude some META-INF files when building a bundled jar using the maven apache felix plugin?

这是我的felix配置

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>

我要提取所有可传递依赖项并将其嵌入,因为我想创建一个可以添加到类路径中的jar.

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.

当我尝试运行jar时,尽管出现异常

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

在SO上找到一个帖子之后,我手动删除了一些似乎来自弹性文件的META-INF/文件.然后,我重新创建了我的jar文件,它起作用了.有没有办法使用felix插件自动执行此操作?

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?

谢谢

推荐答案

看起来,shadow插件使此操作变得容易.所以我改用了shade插件,而不是felix插件.这是我的pom插件配置:

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>

请参见 http://goo.gl/dbwiiJ

这篇关于如何从包中排除META-INF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆