2016-12-05 41 views
1

是否有可能使用maven生成OSGI模块? 通常我可以生成像如何用maven生成OSGI模块?

mvn -B archetype:generate \ 
    -DarchetypeGroupId=org.apache.maven.archetypes \ 
    -DgroupId=com.my.company \ 
    -DartifactId=hello-world 

有没有类似的方式得到一个OSGI模块项目?

回答

3

不确定。原型可能有点过时了。我只需创建一个正常的Maven项目并在父级(see here for an example)上添加bnd-maven-plugin

或者,您可以使用maven-bundle-plugin。 See here

<plugin> 
    <groupId>biz.aQute.bnd</groupId> 
    <artifactId>bnd-maven-plugin</artifactId> 
    <version>3.2.0</version> 
    <executions> 
     <execution> 
      <goals> 
       <goal>bnd-process</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 
<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-jar-plugin</artifactId> 
    <version>2.5</version> 
    <configuration> 
     <archive> 
      <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> 
     </archive> 
    </configuration> 
</plugin> 

有了这个礼物,您的所有模块都将捆绑在一起。如果你需要调整Manifest设置,那么你在你的模块中创建一个bnd.bnd文件。您可以手动编辑或使用bndtools bnd文件编辑器进行编辑。

相关问题