将现有JAR转换为OSGi-bundle [英] Convert existing JAR to OSGi-bundle

查看:1203
本文介绍了将现有JAR转换为OSGi-bundle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要转换为OSGi包的JAR文件。
我没有JAR文件的原始源代码。

I have a JAR file that I need to convert to an OSGi bundle. I do not have the original source code for the JAR file.

我尝试使用以下答案:如何从jar库创建OSGi包?

I tried to use the answers from: How to create OSGi bundle from jar library?

但是,它们已经过时了。

However, they are pretty outdated.

编辑:我需要转换几个,但需要固定数量的罐子。

I need to convert several, but a fixed number of jars.

推荐答案

选项1 - 使用 bnd-platform 构建您的OSGi期望频繁添加/更新Jars时,或者当您可以从Maven存储库中检索依赖项时

Option 1 - use bnd-platform to build your OSGi bundles when expecting frequent additions/updates of Jars, or when you can retrieve your dependencies from Maven repositories

我们使用 bnd-platform (我也是作者)管理第三方依赖项并从中创建OSGi包。您可以将它与从Maven存储库和本地JAR中检索到的两个依赖项一起使用(请参阅自述文件)。如果您经常添加或更新您的依赖项,我建议您尝试 bnd-platform 。这是Gradle的插件,您可以轻松地从此模板开始 - 只需添加您的Jar文件并提供项目README(捆绑符号名称,版本)中描述的配置并运行 gradlew bundles

We use bnd-platform (I am also the author) to manage third party dependencies and create OSGi bundles from them. You can use it with both dependencies retrieved from Maven repositories and local Jars (see the README). If you regularly add or update your dependencies I would suggest that you try bnd-platform. It's a plugin for Gradle, you can easily start with this template - just add your Jar files and provide the configuration as described in the project README (bundle symbolic names, versions) and run gradlew bundles.

选项2 - 使用 bnd 构建您的OSGi捆绑包当您执行一次或添加/更新很少

Option 2 - use bnd to build your OSGi bundles when you do it once or additions/updates are seldom

如果您只进行一次或很少这样的过程,从现有Jar创建OSGi包的简单方法是直接使用命令行上的bnd 。你唯一需要的是Java和bnd jar。您可以使用 wrap 尝试使用 .bnd 文件://www.aqute.biz/Bnd/Formatrel =noreferrer> bnd 的说明(例如,仅导出特定包裹)。

If you only do this process once or seldom, a simple way to create an OSGi bundle from an existing Jar is to directly use bnd on the command line. The only thing you need is Java and the bnd jar. You can use wrap to try to automatically wrap a jar or create a .bnd file with instructions for bnd (e.g. to only export specific packages).

示例.bnd文件:

-classpath: lib/trove-2.0.4.jar
-output: gnu.trove-2.0.4.jar
Export-Package: *;-split-package:=merge-last;-noimport:=true
Import-Package: *
Bundle-Version: 2.0.4
Bundle-Name: GNU Trove Collections Plug-in
Bundle-SymbolicName: gnu.trove

示例电话:

java -jar <path to bnd>.jar trove-2.0.4.bnd

不再直接通过网站提供bnd Jar下载,一个很好的选择是< a href =http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22biz.aQute.bnd%22%20AND%20a%3A%22bnd%22 =noreferrer>下载它来自Maven Central 。

The bnd Jar download is no longer offered directly through the web site, a good alternative is to download it from Maven Central.

这篇关于将现有JAR转换为OSGi-bundle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆