【问题标题】:maven-bundle-plugin problem (OSGI)maven-bundle-plugin 问题 (OSGI)
【发布时间】:2011-05-21 10:20:10
【问题描述】:

我有一个项目使用 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 个 jar 作为结果,一个包含 osgi 内容,一个不包含,因为嵌入式依赖项在将其用作普通 jar 时会导致问题。

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

【问题讨论】:

    标签: maven osgi


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

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

      默认的 pom.xml 应该生成像 foo:bar:1.0.0

      这样的普通库

      另一个pom-osgi.xml 应该生成像 foor:bar-osgi:1.0.0

      这样的 OSGi 库

      使用另一个 pom 构建库

      mvn -f pom-osgi.xml install
      

      【讨论】:

        猜你喜欢
        • 2013-02-10
        • 2011-06-18
        • 2016-07-20
        • 2013-01-12
        • 2017-01-02
        • 2012-04-20
        • 2011-09-12
        • 2011-03-06
        • 2014-05-26
        相关资源
        最近更新 更多