Require-Bundle 和 Import-Package 与 feature.xml 要求 [英] Require-Bundle and Import-Package versus feature.xml requires

查看:34
本文介绍了Require-Bundle 和 Import-Package 与 feature.xml 要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在构建包含多个插件和一个功能的 Eclipse 插件 (lato sensu) 时,我有两种指定依赖关系的方法:

When building an Eclipse plugin (lato sensu) which consists of multiple plugins and one feature, I have two ways of specifying dependencies:

  • 在插件本身中,使用 META-INF/MANIFEST.MF 中的 Require-BundleImport-Package
  • 在功能的 feature.xml 文件中.
  • in the plugins themselves, using Require-Bundle and Import-Package in META-INF/MANIFEST.MF;
  • in the feature.xml file from the feature.

在我的理解中,在插件中声明较低级别的依赖项应该足够了,.为什么我们还有 feature.xml requires 机制?

In my understanding, it should be enough to declare the dependencies at the lower level, i.e. in the plugins. Why do we still have the feature.xml requires mechanism?

更新:Eclipse 帮助中的feature.xml 描述

推荐答案

将特征到特征的依赖机制归类为遗留是不正确的.虽然随着 p2 的出现,确实会安装通过 bundle manifest Require-Bundle 或 Import-Package 指定的依赖项,但结果可能不是您所期望的.

It is incorrect to categorize feature-to-feature dependency mechanism as legacy. While it is certainly true that with advent of p2, dependencies specified via bundle manifest Require-Bundle or Import-Package will be installed, the result may not be what you expect.

考虑您正在构建 JDT 扩展的情况.假设您只依赖 JDT 核心 api(无 UI 扩展).如果你只依赖 OSGi 依赖,当你的插件被安装时,p2 将尽职尽责地安装 JDT 核心包,而不是 UI 包.从 OSGi 的角度来看非常好,但可能不是您想要的.

Consider the case where you are building an extension to JDT. Say you only depend on JDT core api (no UI extensions). If you only rely on OSGi dependencies, when your plugin is installed, p2 will dutifully install JDT core bundle, but not the UI bundle. Perfectly fine from OSGi perspective, but probably not what you intended.

我建议坚持使用功能导入来描述您的高级依赖项,以确保它们已完全安装.仅依赖 OSGi 依赖项最适合自由浮动的捆绑包,这些捆绑包不属于应该作为一个单元安装的更大的东西.

I recommend sticking with feature import to describe your high level dependencies to make sure that they are installed in full. Relying only on OSGi dependencies works best for free-floating bundles that aren't part of something bigger that should be installed as a unit.

这篇关于Require-Bundle 和 Import-Package 与 feature.xml 要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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