OPS4J維基頁面 - "Getting the benefits of maven-bundle-plugin in other project types"描述了一種達到此目的的方法(或多或少)。
您可以在您的pom.xml
中配置依賴關係嵌入和Bundle-ClassPath
指令以匹配WAR插件使用的位置。 maven-bundle-plugin將會生成正確的清單頭文件。
Maven的束-插件的說明可能是這樣的:
<instructions>
<Bundle-ClassPath>.,WEB-INF/classes,{maven-dependencies}</Bundle-ClassPath>
<Embed-Directory>WEB-INF/lib</Embed-Directory>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<!-- ... -->
</instructions>
ETA:使用此方法時,我發現了兩個值得注意的事情:
- 的bundle插件會抱怨缺少
WEB-INF
目錄,因爲當清單目標被執行時,war插件還沒有創建它們(它只運行在la ter階段)
- 雖然它對於實際的webapp沒有意義,
Bundle-ClassPath
指令必須包含「。」,否則捆綁插件會搞亂Import-Packages
標頭。我通過Google在一些JIRA問題中發現了這一點,但我無法再找到該URL。
除此之外,它工作正常。
[Maven Web Project with Apache Felix Plugin]的可能重複](https://stackoverflow.com/questions/19272627/maven-web-project-with-apache-felix-plugin) – bigbadmouse 2017-07-20 13:45:04