Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reference non plugin project to eclipse plugin project

Can I add a reference from an eclipse plugin project to a non plugin jar? This is a jar that I can not change, so i have to use it as is.

Thank you Ido

like image 453
Ido Avatar asked Jul 26 '09 09:07

Ido


2 Answers

The safest approach would be to create a new plugin from your existing jar file:

Select New project -> Plug-In Development -> Plug-in from existing JAR Archives

Then choose the jar file(s) ('Add Externals' on Galileo), name the project and fill in some plug-in properties (optional) and choose whether you want to unzip the jar or keep it as it is. I keep the checkbox checked...

And that's it. Eclipse will autogenerate a plugin project that exports all packages so that it can be used in your plug-in or rcp project.

like image 80
Andreas Dolk Avatar answered Sep 30 '22 05:09

Andreas Dolk


The simplest way to do this is to add the jar to your plugin and modify the classpath.

Copy the jar into a sub-directory of the plugin (e.g. lib), then modify the plugin's classpath (in the manifest editor) to include the plugin root and lib/foo.jar.

In the Manifest Editor, select the Runtime tab and select the Add button on the Classpath pane. Add the jar, e.g. "lib/foo.jar" and select OK, if you look at the manifest source you should see a line like:

Bundle-ClassPath: lib/foo.jar,
 .

If the jar is to be used by other plugins, you can configure the manifest to export the packages in the nested jar, then other plugins can add a dependency to the containing plugin and use it as normal. To do so go to the Runtime tab of the Manifest editor, select Add.. on the Exported Packages section, then select all the packages to be exported. If you look at the manifest you should see all the packages listed like this:

Export-Package: name.seller.rich,
 name.seller.rich.junit,
 name.seller.rich.foo,
 ...
like image 21
Rich Seller Avatar answered Sep 30 '22 05:09

Rich Seller