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
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.
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,
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With