Require-Bundle and Import-Package versus feature.xml requires

When creating an Eclipse plugin (lato sensu), which consists of several plugins and one function, I have two ways to set dependencies:

  • in the plugins themselves, using Require-Bundle and Import-Package in META-INF/MANIFEST.MF ;
  • in the feature.xml file from this function.

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


Update: feature.xml description in Eclipse Help

+7
source share
2 answers

It is incorrect to classify the mechanism of dependence on function-function as a legacy. Although it is certainly true that with the advent of p2, dependencies defined through the Require-Bundle or Import-Package manifest will be installed, the result may not be what you expect.

Consider the case when you create an extension for JDT. Let's say you depend only on the api's JDT kernel (without a user interface extension). If you rely only on OSGi dependencies when your plugin is installed, p2 will dutifully install the JDT kernel package, but not the UI package. Absolutely excellent from an OSGi point of view, but probably not what you intended.

I recommend sticking with feature imports to describe your high-level dependencies to make sure they are fully installed. Relying only on OSGi dependencies, it is best suited for free-floating packages that are not part of something larger that needs to be installed as a unit.

+6
source

The Eclipse function is a concept for managing plugins to provide more abstract text.

For example, there are more than twenty plug-ins for C / C ++ development tools, so CDT has several functions for organizing these plug-ins in higher-level abstract abstractions for basic functions, ui, build, etc.

It also helps simplify the installation process, users only need to know the top function (with a friendly name) of the CDT. A P2 API or classic installation control can find plugins and helper functions, including the top function, and then install them.

However, the function was NOT able to help you create a system with a high module, since it does not provide any functionality by itself. It is not part of the OSGi specification; it is inherited from Eclipse 2.x or even an older version.

The package is essential for OSGi. According to the specification, any kit could not use other classes except for declaring a wire with a package of classes. Require-Bundle and Import-Package are ways to create wires.

In short, a function and a plugin are completely different concepts. The feature, including plugins, does different things compared to the Import-Package package.

Update:

The required feature.xml tag is a legacy. The goal is to define the dependencies of this function with other plugins / functions to help the update manager find the damaged dependencies when installing or updating this function. It determines the dependencies of this function with other plugins, but is used by the update manager to install or update. The package Import-Package declares the actual and actual dependency between your package and another module in the OSGi system.

Since eclipse uses p2 as its initialization manager, there is no need to declare a 'require' tag in your feature.xml. P2 recognizes the dependencies between your package and other modules declared as "Import-Package" or "Require-Bundle." P2 will not install or update your function if any dependency fails.

+3
source

All Articles