首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用maven-bundle-plugin索引JAR

使用maven-bundle-plugin索引JAR
EN

Stack Overflow用户
提问于 2012-10-21 08:25:53
回答 1查看 2.8K关注 0票数 1

我正在尝试使用META-INF/INDEX.LIST 2.3.7构建一个包含索引( maven-bundle-plugin )的包。

我的插件配置如下

代码语言:javascript
复制
  <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
      <archive>
        <index>true</index>
      </archive>
      <instructions>
        <!-- other things like Import-Package -->
        <Include-Resource>{maven-resources}</Include-Resource>
      </instructions>
    </configuration>
  </plugin>

但是META-INF/INDEX.LIST不会出现在罐子里。我试着用

代码语言:javascript
复制
  <Include-Resource>{maven-resources},META-INF/INDEX.LIST</Include-Resource>

但那会失败的

代码语言:javascript
复制
[ERROR] Bundle com.acme:project::bundle:1.0.0-SNAPSHOT : Input file does not exist: META-INF/INDEX.LIST
[ERROR] Error(s) found in bundle configuration

这并不奇怪,因为META-INF/INDEX.LIST不是在target/classes中,而是由Maven Archiver动态生成的。

编辑1

当我使用jar而不是bundle打包时,索引就在那里了。

编辑2

我用的是Maven 3.0.4

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-30 16:53:39

maven-bundle-plugin源代码中进行挖掘,看起来当前版本(2.3.7)忽略了归档配置的index属性。它还忽略了compressforcedpomPropertiesFile。存档配置的唯一属性是addMavenDescriptormanifestmanifestEntriesmanifestFilemanifestSections

我不确定是否有其他方法只使用maven-bundle-plugin来操作创建的归档文件。

作为一种可能的解决办法,您可以在包创建后使用maven- jar插件重新jar,告诉jar插件创建索引,但使用包插件创建的清单。

代码语言:javascript
复制
<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
        <!-- unpack bundle to target/classes -->
        <!-- (true is the default, but setting it explicitly for clarity) -->
        <unpackBundle>true</unpackBundle>
        <instructions>
            <!-- ... your other instructions ... -->
            <Include-Resource>{maven-resources}</Include-Resource>
        </instructions>
    </configuration>
</plugin>
<!-- List this after maven-bundle-plugin so it gets executed second in the package phase -->
<plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>jar</goal>
            </goals>
            <configuration>
                <!-- overwrite jar created by bundle plugin -->
                <forceCreation>true</forceCreation>
                <archive>
                    <!-- use the manifest file created by the bundle plugin -->
                    <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    <!-- bundle plugin already generated the maven descriptor -->
                    <addMavenDescriptor>false</addMavenDescriptor>
                    <!-- generate index -->
                    <index>true</index>
                </archive>
            </configuration>
        </execution>
    </executions>
</plugin>

我不太熟悉包存档中所需的内容,因此您可能需要再次检查是否所有内容都是正确的。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12996182

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档