OSGI:在maven-bundle-plugin中生成bundle-classpath

时间:2011-01-30 11:57:17

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

我正在尝试将所有来自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解决了这个问题,但这听起来并不合理。

感谢

2 个答案:

答案 0 :(得分:6)

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

另外,你使用的是什么版本的bnd插件?这些功能从1.2.0 +开始提供。

答案 1 :(得分:1)

OSGified的经典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-Dependency位于instructions元素