maven-bundle-plugin问题(OSGI)

时间:2010-12-07 07:31:08

标签: maven osgi

我有一个项目,使用maven-bundle-plugin生成一个OSGI包。配置如下所示:

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.1.0</version>
    <extensions>true</extensions>
    <inherited>true</inherited>
    <configuration>
        <instructions>
            <Export-Package>${bubble.osgi.exports}</Export-Package>
            <Import-Package>${bubble.osgi.imports}</Import-Package>
            <Embed-Dependency>${bubble.osgi.embed.dependencies}</Embed-Dependency>

            <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
        </instructions>
        <versions>
            <bubble.osgi.version.clean>${project.version}</bubble.osgi.version.clean>
        </versions>
    </configuration>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>cleanVersions</goal>
            </goals>
        </execution>
    </executions>
</plugin>

项目的结果是一个包含所有osgi内容,嵌入式依赖项等的jar文件。我宁愿有2个罐作为结果,一个包含osgi的东西,一个没有,因为嵌入式依赖项在使用它时就像普通jar一样会引起问题。

除了使用maven程序集插件之外还有其他方法吗?

2 个答案:

答案 0 :(得分:2)

您可以将maven-bundle-plugin配置移动到单独的配置文件中并使用类似

的内容

mvn package -Posgi 或默认。但是每个构建只会产生一个工件。

答案 1 :(得分:2)

我建议使用2个不同的pom.xml文件(在项目中),这将产生2个不同的工件。

默认pom.xml应生成普通库,如 foo:bar:1.0.0

另一个pom-osgi.xml应生成OSGi库,如 foor:bar-osgi:1.0.0

使用另一个pom来构建库

mvn -f pom-osgi.xml install