6

In Dependencies tab, I have a choice between plug-ins and packages. What's the difference between them? For org.eclipse.compare, I have it in imported package and also in plug-ins.

enter image description here

enter image description here

I find the jar file in plugins directory, but I don't know where the package file of org.eclipse.compare is located.

enter image description here

In the export menu, it seems like that there seems to be only exporting to jar, not exporting a plugin or packages. How can I export packages?

enter image description here

ADDED

Based on this post - How to import a package from Eclipse? and shiplu's answer. This is what I came to understand. Please correct me if I'm wrong.

  1. In eclipse, when I use come external class, I can use Quick-Assistant or Organize imports (Ctrl-Shift-O) to resolve the reference. Eclipse adds the package that contains the class in Imported Packages for the project that I'm working on. A package can contain multiple classes (types). Eclipse understands what plugin contains the package, and resolve the reference issues.
  2. A plug-in (jar file) can contain multiple packages. By specifying a required plug-ins in the dependencies tab, we can reference all the packages (and classes in the packages) for all the java projects in the eclipse IDE.

And from my experience, I had to add all the dependencies in order to make headless RCP standalone (http://prosseek.blogspot.com/2012/12/headless-rcp-standalone.html).

Community
  • 1
  • 1
prosseek
  • 182,215
  • 215
  • 566
  • 871
  • 1
    1. Pretty much. When you reference packages, Eclipse doesn't care about which bundles provide those packages, this is dynamically resolved at runtime. And yes, a package is the usual Java package so it can contain multiple java classes. 2. A bundle is a deployment unit which can contain multiple packages. When you "require plug-in" you implicitly can reference all the packages it provides, but you are always referencing the packages from this particular bundle/plug-in. – Svilen Dec 19 '12 at 21:35

3 Answers3

4

An Eclipse plug-in is basically an OSGi bundle with additional plugin.xml file which Eclipse IDE understands and interprets.

So the answer to your question lies in the OSGi specification and the OSGi programming model, since, very simply put, Eclipse is an Application running on implementation of OSGi called Equinox.

OSGi is all about having modular applications and so it defines several levels of modularity. One such level is a bundle-level (module-level) modularity and more fine grained level is the package level modularity.

So you can have your OSGi application (a set of bundles; eclipse is just that) which consists of db-bundle (which provides data store services), app-domain-bundle (which provides your application domain services) and remote-bundle (which exposes to the web your application via REST for example).

And then you say remote-bundle depends on domain-bundle which depends on db-bundle. Which is all good, but cripples the inherent modularity OSGi provides, because you are basically restricting your application to specific implementations of db-bundle and remote-bundle i.e. to specific implementations of the services they provide.

Instead, you can establish the above dependencies not between bundles but between packages i.e. establish a service-level dependencies. Then you say domain-bundle requires dbstore.service package to run, it doesn't care which bundle provides it it just needs an instance of this service to be able to work. So you can have multiple bundles providing implementations of the dbstore.service, and the domain-bundle can pick and choose at runtime what service to use.

It is really hard to explain OSGi concepts in just a several sentences, I'd really suggest you dig around the web on this and maybe even have a look at the OSGi specification.

Another way to explain it is to say that bundle/plug-in is a jar file with specific structure and metadata descriptors (MANIFEST.MF and plugin.xml), which describe its contents in Java language concepts - which java packages and services this specific jar contains and will expose to the OSGi runtime so that they can be consumed by other bundles. I.e. the bundle is the physical deployable entity while the descriptors are metadata about what actually is being deployed.

EDIT: Package or Service-level dependencies also have some drawbacks, as Lii points out in the comments below, the main one being that it adds complexity and dynamics to the dependency model. Have a look at her or his comment below - it is worth reading!

Svilen
  • 1,377
  • 1
  • 16
  • 23
  • If you have a naming convention in which there are no two packages named the same in any of the bundles, does the import directive still make sense? – Vlad Ilie Nov 11 '13 at 06:19
  • You should always prefer package dependencies as opposed to bundle dependencies - this is how OSGI is meant to work and this is how the true dynamic nature of it shines. – Svilen Nov 11 '13 at 09:16
  • 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.) – Lii Sep 25 '18 at 07:15
1

You use Imported Packages when you want to use a specific package but do not care which plugin provides it. OSGI will choose one for you.

Cratylus
  • 52,998
  • 69
  • 209
  • 339
0

Eclipse plugins is something like extension to the IDE itself. But imported packages are actually packages that you'll use in your current project.

One is for development IDE another is for the project you are coding.

Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187
  • I think I get the point, but I'm not sure the pros and cons between them. Could you care to check my other question? - http://stackoverflow.com/questions/13959891/why-do-we-need-imported-packages-when-we-have-required-plug-ins-in-eclipse-p – prosseek Dec 19 '12 at 20:29