【发布时间】:2016-12-05 16:39:23
【问题描述】:
是否可以使用 maven 生成 OSGI 模块? 通常我可以生成一个类似的项目
mvn -B archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=com.my.company \
-DartifactId=hello-world
有没有类似的方法来获取 OSGI 模块?
【问题讨论】:
是否可以使用 maven 生成 OSGI 模块? 通常我可以生成一个类似的项目
mvn -B archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=com.my.company \
-DartifactId=hello-world
有没有类似的方法来获取 OSGI 模块?
【问题讨论】:
不确定。原型可能有点过时了。我只是创建了一个普通的 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 文件编辑器进行编辑。
【讨论】: