Why do we need `Imported Packages` when we have `Required Plug-ins` in Eclipse plugin dependencies?
Asked Answered
S

2

19

In developing Eclipse application, the dependencies tab in MANIFEST.MF has two columns.

One is Required Plug-ins and the other is Imported Packages.

Why do we need Imported Packages when we have Required Plug-ins?

The comment has it that "this plug-in depends without explicitly identifying their originating plug-in", but I'm not sure in what case one doesn't want to explicitly identify their originating plug-in, and what's the advantage of it?

enter image description here

ADDED

Related question - What's the difference between Eclipse Packages and Plug-ins?

Subscapular answered 19/12, 2012 at 19:40 Comment(1)
Not every imported package contains plug-ins. Use required plug-ins first. Use imported packages when necessary.Denture
M
13

Importing a package provides an extra level of indirection over requiring a bundle.

Consider the case of some standard API... org.standard.framework. Suppose two companies implement this API, maybe you have bundles com.abc.framework and com.xyz.framework. Both of these implementation bundles would export org.standard.framework package.

Now suppose, you need an org.standard.framework implementation, but you don't particularly care which one. If you require either com.abc.framework or com.xyz.framework bundle, you are tying yourself to a particular implementation. With an import-package directive, you are letting OSGi serve as an indirection layer.

Another advantage of import-package is that your dependencies do not need to change if a package is moved to another bundle. This situation can arise during refactoring when bundles are broken up or combined.

For these reasons, OSGi spec writers now generally recommend using the relatively newer import-package directive over require-bundle. The problem is that not all of the bundles are ready for this. Many do not yet specify a version when exporting a package. This makes import-package impractical in many cases.

Military answered 19/12, 2012 at 21:37 Comment(1)
Nice explanation! But I think it is a good idea to also add something about the disadvantages of import-package compared to require-bundle: With require-bundle it is easier to quickly get a clear picture of what components your project depends upon. It is also easier to find the the dependency artifacts. The price of the flexibility of import-package is reduced clarity. (I think this aspect is very important, and often not taken into consideration when people argue that import-package should be used.)Almena
L
0

Specifying the dependency on a whole plugin, rather, then only a required package may create a cyclic dependencies, if you have a lot of plugins. It's better practise to specify only packages you actually require. For the small amount of plugins of if you are sure, you are able to efficiently maintain dependencies, you are welcome to simplify your life by specifying the whole plugin. Hope this helps.

Logia answered 19/12, 2012 at 19:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.