Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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

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?


Update: feature.xml description in the Eclipse Help

like image 522
Robert Munteanu Avatar asked Dec 26 '10 22:12

Robert Munteanu


1 Answers

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.

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.

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.

like image 51
Konstantin Komissarchik Avatar answered Jan 24 '23 23:01

Konstantin Komissarchik