我对 osgi 和 bndtools 还很陌生,但在过去的几天里,我设法使用 bnd ant 任务创建 jar->bundle,并将我们的第 3 方 jar 包装为 bundle(对于那些尚未定义“Export-包'在清单文件中)。我必须评论说,bndtools 在出口和进口方面完成所有繁重的工作似乎很棒,所以感谢您在这个项目上的辛勤工作!
我有两个问题,也许你可以解释一下:
1
我正在尝试让捆绑包加载到 felix 中,并立即遇到解析错误。在这个基本场景中,我们有一个名为 omniquery_common 的内部包,它使用了几个 3rd 方 jar,包括 gson。当我解决我得到这个:
Unable to resolve <<INITIAL>> version=null:
missing requirement Require[osgi.identity]{}{filter=(osgi.identity=omniquery_common)} [caused by:
Unable to resolve omniquery_common version=1.0.0.0:
missing requirement Require[osgi.wiring.package]{}{filter=(&(osgi.wiring.package=com.google.gson)(version>=2.2.0)(!(version>=3.0.0)))}]
对我来说,omniquery_common 正在导入 com.google.gson(版本至少为 2.2 且小于 3.0)。gson 包正在导出版本 2.2.4,所以这应该满足它的依赖关系,但不是。
你能帮我理解我是怎么弄错的吗?
omniquery_common 的清单:
Manifest-Version: 1.0
Bnd-LastModified: 1442336803995
Bundle-ManifestVersion: 2
Bundle-Name: omniquery_common
Bundle-SymbolicName: omniquery_common
Bundle-Version: 1.0.0.0
Created-By: 1.8.0_40 (Oracle Corporation)
Export-Package: com.radian6.omni.common.osgi;version="1.0.0"
Import-Package: com.google.gson;version="[2.2,3)",com.radian6.omni.commo
n.util,org.apache.commons.io;version="[1.4,2)",org.apache.commons.lang;
version="[2.6,3)",org.junit
Private-Package: com.radian6.omni.common.core
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))"
Tool: Bnd-2.4.1.201501161923
gson 的清单:
Manifest-Version: 1.0
Export-Package: com.google.gson;version=2.2.4, com.google.gson.annotat
ions;version=2.2.4, com.google.gson.reflect;version=2.2.4, com.google
.gson.stream;version=2.2.4, com.google.gson.internal;version=2.2.4, c
om.google.gson.internal.bind;version=2.2.4
Bundle-ClassPath: .
Built-By: inder
Bundle-Name: Gson
Created-By: Apache Maven 3.0.4
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: Google Gson Project
Bundle-ContactAddress: http://code.google.com/p/google-gson/
Bundle-Version: 2.2.4
Build-Jdk: 1.7.0_21
Bundle-ManifestVersion: 2
Bundle-Description: Google Gson library
Bundle-SymbolicName: com.google.gson
Archiver-Version: Plexus Archiver
2
如果我更改“运行要求”列表中捆绑包的顺序,将 gson 捆绑包放在omniquery_common 之前,我会得到
Unable to resolve <<INITIAL>> version=null:
missing requirement Require[osgi.identity]{}{filter=(osgi.identity=com.google.gson)}
我觉得不直观-我会认为该列表中的捆绑顺序无关紧要...?