我正在尝试使用META-INF/INDEX.LIST 2.3.7构建一个包含索引( maven-bundle-plugin )的包。
我的插件配置如下
<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不会出现在罐子里。我试着用
<Include-Resource>{maven-resources},META-INF/INDEX.LIST</Include-Resource>但那会失败的
[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
发布于 2012-10-30 16:53:39
在maven-bundle-plugin源代码中进行挖掘,看起来当前版本(2.3.7)忽略了归档配置的index属性。它还忽略了compress、forced和pomPropertiesFile。存档配置的唯一属性是addMavenDescriptor、manifest、manifestEntries、manifestFile和manifestSections。
我不确定是否有其他方法只使用maven-bundle-plugin来操作创建的归档文件。
作为一种可能的解决办法,您可以在包创建后使用maven- jar插件重新jar,告诉jar插件创建索引,但使用包插件创建的清单。
<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>我不太熟悉包存档中所需的内容,因此您可能需要再次检查是否所有内容都是正确的。
https://stackoverflow.com/questions/12996182
复制相似问题