Search code examples
eclipseeclipse-rcp

Eclipse RCP - Use Classes from a library that are imported from another plugin?


follow situation.

-pluiginCore <- includes many Libraries (libA,liB) via pom.xml, do nothing else

-pluginA..F <- want use classes from libA. -pluginF..Z <- want use classes from libB.

Is this possible with RCP? Is this a good way? Do I need to import via pom.xml libA and LibB in each plugin where I wanna use it?

I added pluginCore as a dependency of pluginA but still cant use libA.


Solution

  • You have to do this using the directives in the MANIFEST.MF of the plugins.

    For the plugin which contains the libraries you use the Bundle-ClassPath to specifies the jars in the plugin. For example:

    Bundle-ClassPath: .,
     lib/jogg-0.0.7.jar,
     lib/jorbis-0.0.15.jar,
     lib/vorbisspi1.0.2.jar
    

    The . entry is for the normal code in the plugin, the other entries are jars in a lib directory.

    You must also specify the additional jars in the build.properties for the plugin.

    You use the Export-Package directive to say which packages from these jars are available to other plugins:

    Export-Package: com.jcraft.jogg,
     com.jcraft.jorbis
    

    Plugins which wish to refer to these packages can either use Require-Bundle to add a dependency to the plugin exporting the packages, or they can use Import-Package to let Eclipse find the imported package.