【发布时间】:2020-07-15 14:33:59
【问题描述】:
我正在从头开始为 Eclipse smarthome 编写一个 OSGi 包,并且需要导出某个包。 这是必需的,因为目前 karaf 控制台向我显示此错误:
Unresolved requirement: Import-Package: com.pubnub.api
在清单文件中,我可以看到我导入了同一个包,等等。我使用maven导入它,按照官方文档here。
OSGi 开发支持告诉我必须“导出 com.pubnub.API 包以便我的包导入它”,但我不知道该怎么做。 看来我应该“找到或制作一个导出 PubNub API 的包”,但这个答案让我感到困惑。
我想我需要在清单中的某处添加一行,例如“export-package etc”,但我不知道在哪个清单中,或者这是否是正确的方法。我是 OSGi 框架的初学者。
我尝试搜索类似的线程(如this 和this),但我认为它们对我的情况没有帮助。
为了清楚起见,这是我的清单文件:
Import-Package: org.eclipse.smarthome.core.library.types, org.eclipse.smarthome.core.thing, org.eclipse.smarthome.core.thing.binding, org.eclipse.smarthome.core.types, com.google.gson;version="[2.8,3)", com.pubnub.api, com.pubnub.api.builder, com.pubnub.api.callbacks, com.pubnub.api.endpoints.pubsub, com.pubnub.api.models.consumer, com.pubnub.api.models.consumer.pubsub, com.pubnub.api.models.consumer.pubsub.message_actions, com.pubnub.api.models.consumer.pubsub.objects, org.slf4j;version="[1.7,2)"
这是我的pom:
<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>2.5.3-SNAPSHOT</version>
</parent>
<artifactId>org.openhab.binding.safehome_se</artifactId>
<name>openHAB Add-ons :: Bundles :: SafeHome_SE Binding</name>
<dependencies>
<dependency>
<groupId>com.pubnub</groupId>
<artifactId>pubnub-gson</artifactId>
<version>4.31.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
【问题讨论】:
-
您必须提供一些有关您使用的 maven 插件的信息...
-
我以为我没有使用任何插件,因为我的 pom 没有任何插件标签。然而,启用“显示有效的 pom”它显示 - 在我认为是 maven 默认插件中 - 它显示 bnd、karaf 和 openhab sat (org.openhab.tools.sat)
-
有不同的 bnd 插件。但是,通常它们在 pom 中有一个清单部分或有一个 bnd 文件。通常您不指定 Import-Package,这是由 bnd 计算的……您可以分享您的工作空间,因为您似乎很迷茫吗?
标签: java maven osgi osgi-bundle manifest.mf