Maven 2 OSGI:在maven bundle插件中生成bundle类路径

Maven 2 OSGI:在maven bundle插件中生成bundle类路径,maven-2,osgi,bundle,war,pom.xml,Maven 2,Osgi,Bundle,War,Pom.xml,我正在尝试将WebINF/lib中的所有JAR添加到Bundle类路径中。 我看到了几种方法,但没有一种有效: 1) 加 *;范围=编译|运行时;内联=真 WEB-INF/lib 真的 2) 加 ,{maven dependencies},WEB-INF/classes 当然,在“Bundle类路径”中逐个编写jar可以解决问题,但这听起来不是一个合理的解决方案 在您的第一个代码片段中,谢谢您,在编写时使用不是很有效吗?上面的例子似乎表明了这一点 另外,您使用的是什么版本的bnd插件?这些功

我正在尝试将WebINF/lib中的所有JAR添加到Bundle类路径中。 我看到了几种方法,但没有一种有效:

1) 加

*;范围=编译|运行时;内联=真
WEB-INF/lib
真的
2) 加

,{maven dependencies},WEB-INF/classes
当然,在“Bundle类路径”中逐个编写jar可以解决问题,但这听起来不是一个合理的解决方案


在您的第一个代码片段中,谢谢您,在编写时使用
不是很有效吗?上面的例子似乎表明了这一点


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

作为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>

org.apache.felix
maven捆绑插件
真的
捆绑清单
进程类
显示
org.example
webappcontextpath
,WEB-INF/classes,{maven dependencies}
*;范围=编译|运行时
WEB-INF/lib
战争

请注意,
嵌入依赖项
位于
指令
元素中

第一个选项在我编写*时开始工作;scope=compile | runtime我知道这是一篇老文章,但是我认为值得补充的是,上面提供的第二个选项必须与第一个选项结合使用,即{maven dependencies}变量只能在指定嵌入依赖项后使用,和用于控制包类路径中嵌入依赖项的位置
<Bundle-ClassPath>.,{maven-dependencies},WEB-INF/classes</Bundle-ClassPath>
<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>