如何使用 Maven 将第 3 方 OSGi 捆绑包添加到部署包中?
我正在构建要在 OSGi 容器中运行的应用程序。我使用 Maven 和 Apache Felix 的 Maven Bundle 插件为我自己的模块设置 OSGi 清单,效果非常好。
现在,我将我的包与几个第三方库一起部署到 OSGi 容器中。当我从 Maven 存储库获取它们时,其中一些已经是 OSGi 化的,其他的我想转换成 OSGi 兼容的 jar。我想建立一个 Maven 项目来收集所有依赖项,并将每个依赖项放入自己的 OSGi jar 中。最终目标是将这些 jar 和我自己的 jar 收集到一个程序集中,我可以将其用作独立的部署包。
我知道如何将标准 jar 转换为 OSGi jar,我有一种(有点黑客的)方法 合并多个 OSGi 包,即使我可能不应该这样做。但是,如果我有一个已经很好的依赖项,并且我只想将其从存储库复制到我的程序集中,我应该使用 Maven 的哪一部分?捆绑插件是错误的,如果依赖项已经与 OSGi 兼容,它会弄乱清单。我是否使用依赖插件、程序集插件或其他插件?
我感觉我在这里忽略了一些非常简单的事情。
I'm building my application to run in an OSGi container. I use Maven and the Maven Bundle Plugin from Apache Felix to set up the OSGi manifests for my own modules and that works great.
Now, I'm deploying my bundles into an OSGi container together with several 3rd party libraries. Some of these are already OSGi-fied when I get them from the Maven repos, others, I want to convert into OSGi-compatible jars. I want to set up a Maven project that collects all dependencies, and puts each in its own OSGi jar. The ultimate goal is to collect these jars and my own into an assembly that I can use as a standalone deployment package.
I know how to convert standard jars to OSGi jars, and I have a (somewhat hackish) approach to merge multiple OSGi bundles, even if I probably shouldn't. But if I have a dependency that's already fine as it is, and I just want to copy it from the repo into my assembly, what part of Maven do I use? The bundle plugin is wrong, it messes up the manifests if a dependency is already OSGi-compatible. Do I use the dependency-plugin, the assembly plugin or something else?
I have the feeling I'm overlooking something very simple here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您看过 PAX 工具吗?特别是 Pax-Runner 和
pax-construct...他们不仅为您提供了一个不错的入门模板,而且还免费解决您提到的大多数问题。
Did you have a look at the PAX tools? In particular Pax-Runner and
pax-construct... They do not only give you a nice template to start with, but also solve most the problems you mentioned for free.
我们使用的许多库未经供应商 OSG 化,并且在 Spring 包存储库中不可用。我们也有很多这样的东西,并且希望将它们全部部署在一起,毫无麻烦。为此,我们创建了一个 2 层 Maven 设置:
一旦它变成一个程序集(我们的是一个 tar 文件),我们就把它部署到我们的服务器上。我们更进一步,使用这个第三方库的集合作为 Eclipse 构建环境的目标平台。但这可能与你无关。
We use many libraries which are not OSGified by the vendor and which are not available on the Spring bundle repository. We also have many of these and want to deploy them all together hassle free. For this we have created a 2-layer maven setup:
Once it is turned into an assembly (ours is a tar file) we deploy this to our servers. We have gone one step further and used this assembly of 3rd party libraries as the Target Platform for our Eclipse build environment. But this may be irrelevant for you.
您可以从 Spring 捆绑存储库获取许多常见工件的 OSGi 友好版本。所以您可能不必自己做。
请参阅如何配置 Maven 的捆绑包存储库的详细信息。
(将更新一些尚未作为捆绑包提供的想法)
You can get OSGi friendly versions of many common artifacts from the Spring bundle repository. So you may not have to do it yourself.
See details of how to configure the bundle repository for Maven.
(will update with some ideas for those that aren't available as bundles already)