【问题标题】:OSGI: generate bundle-classpath in maven-bundle-pluginOSGI:在 maven-bundle-plugin 中生成 bundle-classpath
【发布时间】:2011-06-18 02:00:28
【问题描述】:

我正在尝试将 web-inf/lib 中的所有 jar 添加到 Bundle-ClassPath。 我看到了几种方法,它们都不起作用:

1) 添加

<Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
<Embed-Directory>WEB-INF/lib</Embed-Directory>
<Embed-Transitive>true</Embed-Transitive>

2) 添加

<Bundle-ClassPath>.,{maven-dependencies},WEB-INF/classes</Bundle-ClassPath>

当然,在“Bundle-ClassPath”中一个一个地写jar可以解决问题,但听起来不是一个合理的解决方案。

谢谢

【问题讨论】:

  • 我知道这是一篇旧帖子,但我认为值得补充的是,您上面提供的第二个选项必须与第一个选项结合使用,即。 {maven-dependencies} 变量只有在你指定了嵌入依赖后才能使用,用于控制嵌入依赖在 Bundle-ClassPath 中的位置

标签: maven-2 osgi bundle war pom.xml


【解决方案1】:

在您的第一个代码 sn-p 中,不会使用 &lt;Embed-Dependency&gt;,因为您已经编写了工作? http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html 的示例似乎表明它会。

另外,您使用的是什么版本的 bnd 插件?这些功能自 1.2.0+ 起可用。

【讨论】:

  • 第一个选项在我编写 *;scope=compile|runtime 时开始起作用
【解决方案2】:

一个被 OSG 化的经典 web 应用的工作示例

<plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                        <configuration>
                            <instructions>
                                <Private-Package>org.example</Private-Package>
                                <Web-ContextPath>webappcontextpath</Web-ContextPath>
                                <Bundle-ClassPath>.,WEB-INF/classes,{maven-dependencies}</Bundle-ClassPath>
                                <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
                                <Embed-Directory>WEB-INF/lib</Embed-Directory>
                            </instructions>
                            <supportedProjectTypes>
                                <supportedProjectType>war</supportedProjectType>
                            </supportedProjectTypes>
                        </configuration>
                    </execution>
                </executions>
</plugin>

注意Embed-Dependencyinstructions 元素内

【讨论】:

    猜你喜欢
    • 2011-05-21
    • 2013-02-10
    • 2016-07-20
    • 2017-01-02
    • 2014-05-26
    • 2012-04-20
    • 2015-02-20
    • 2010-11-25
    • 2011-03-06
    相关资源
    最近更新 更多