Search code examples
eclipse-pluginosgi-bundletychop2manifest.mf

Bundle Manifest dependencies


Recently I have been assigned to improve the structure of inter-dependencies that an Eclipse plugin has. Let's call it "core" and assume that the following manifest describes this eclipse plug-in where all the other plug-ins point to in order for them to access services (RMI, OSGi services). These services are reachable by using either "rmiservices.jar" (Maven generated artifact) and another eclipse plug-in called "org.osgiservice". Other bundles reference "core" bundle and use the Export-Package declaration in order to use these services.

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: core
Bundle-SymbolicName: coreid;singleton:=true
Bundle-Version:  0.0.1
Bundle-Activator: org.sample.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Export-Package: org.sample.api, 
 org.rmiservice,
 org.osgiservice
Bundle-Localization: plugin
Bundle-ClassPath: lib/rmiservices.jar
Require-Bundle: org.osgiservice;bundle-version="1.0.0";visibility:=reexport

Questions that arise in order to improve the dependency structure are:

  1. The "core" plug-in includes within its generated jar the rmiservices.jar. Would it be better having rmiservices.jar as a separate bundle instead?
  2. rmiservices.jar is a maven generated artifact. Would there be a benefit moving it to a P2 repository and expose it inside a target definition?

Solution

  • You should put the jar into its own bundle. If your application grows, you might need to access that library from different bundles. With local jars you risk different versions being loaded by different bundles (due to those local jar copies), leading to very strange errors at runtime.

    If the jar is available in P2, then you can easily build your complete application using Tycho. The automation and reproducability of the build process is well worth the shortly longer build time.