使用DS和maven-bundle-plugin生成清单的正确方法是什么?

时间:2016-01-20 20:56:00

标签: maven osgi declarative-services bnd maven-bundle-plugin

我今天使用maven-bundle-plugin来生成我的项目的清单。由于其他限制,我的模块使用" jar"包装(我不能使用"捆绑"包装),目前,我的pom看起来像这样:

<plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
      <archive>  
        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
      </archive> 
   </configuration>
</plugin>     
<plugin>
  <groupId>org.apache.felix</groupId>
  <artifactId>maven-bundle-plugin</artifactId>
  <executions>
    <execution>
      <id>bundle-manifest</id>
      <phase>process-classes</phase>
      <goals>
        <goal>manifest</goal>
      </goals>
      <configuration>
        <instructions>
         ...
        </instructions>
      </configuration>
    </execution>
  </executions> 
</plugin>   

我现在想要生成一个服务组件&#39;标题和我带注释的组件中的DS xml描述符,但添加&#34; <_dsannotations>*</_dsannotations>&#34;不起作用:

  1. 正确生成了Service-Component标头,但jar中没有xml
  2. 如果我在没有干净目标的情况下重建我的maven项目,那么&#39; Service-Component&#39; header有重复引用:在挖掘代码之后,插件使用来自target / classes / META-INF / MANIFEST.MF的旧生成的清单,并将其与新生成的清单合并。 &#39;服务组件&#39;然后连接
  3. 那么,我应该如何配置我的pom才能工作?现在,我使用&#39; unpackBundle&#39;选项(为了让我的包中有xml)和一个空的src / main / resource / MANIFEST.MF(为了绕过旧清单的合并):它看起来很难看: - )

    此外,&#39; -bven-plugin&#39;按预期工作,但与maven的集成可能太轻(或没有记录?),因为全局配置&#39;在父pom中,生成Bundle-SymbolicName或Bundle-Name等。

    谢谢!

1 个答案:

答案 0 :(得分:1)

有一个更新的maven插件,它更接近bnd和maven。此插件不会接管jar目标并正确遵循maven阶段。

查看http://njbartlett.name/2015/03/27/announcing-bnd-maven-plugin.html