【问题标题】:Avoid copying some packages to OSGi Bundle避免将某些包复制到 OSGi Bundle
【发布时间】:2015-08-28 07:54:22
【问题描述】:

在使用 maven 捆绑插件创建 OSGi 捆绑包时,我想从复制中排除一些包。

我在导出部分使用了!package name。但由于我使用的是@openejb-core-${openejb.version}.jar!/**,因此在包含资源部分,该包被复制到包中。

如何避免使用 maven bundle 插件复制特定包或一组包?

我可以在资源部分使用名称,但我不想一一列出。

【问题讨论】:

    标签: java maven osgi apache-felix maven-bundle-plugin


    【解决方案1】:

    通常,osgi 包的构建部分如下所示:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-scr-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-Category>Your Category/Company</Bundle-Category>
                        <Import-Package>
                           <!-- put here some optional depependencies which are already provided by other bundles -->
                            org.apache.lucene.*;resolution:=optional,
                            *
                        </Import-Package>
                        <Export-Package>
                            com.yourproject.code.to.be.exported.*;version=${project.version}
                            <!-- exclude packages by negating with the prefix !, see http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html for more info -->
                            !com.do.not.include.package.*;version=x.y.z
                        </Export-Package>
                        <Embed-Dependency><!--put here some thirdparty artifacts you want to embed in your bundle--></Embed-Dependency>
                        <Include-Resource>{maven-resources}</Include-Resource>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    另见http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html

    【讨论】:

    • 是的。我知道这个。我想在我的包中包含一些资源。所以我把@openejb-core-${openejb.version}.jar!/** 然后它复制资源+所有类文件到包,即使我不导出其中一些包。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-03
    • 2015-02-09
    • 2010-11-25
    • 2020-11-03
    • 2015-07-20
    相关资源
    最近更新 更多