Convert jars to plugins using eclipse project

Ajay Lamba
2 min readSep 21, 2022

--

While developing an OSGi/RCP application, you would need third party jars and plugins for adding the dependencies. But who uses jars in an OSGi/RCP application these days you say, right? I agree! We should always use plugin based dependencies in RCP applications so that we have better control over the scope and dependencies across the product. The plugins are available on public repositories such as this.

But not all the required plugins are present on the public repositories and hence sometimes we would need to convert the jars to plugins. There is a very good maven plugin to convert the jars available on maven repo to plugins automatically. But what about the jars which are not present on maven central repo?

Convert any jar to plugin —

  1. First of all create a new eclipse project by selecting ‘File->New->Other->Plug-in from existing JAR Archives’.
  2. Click ‘Next’ button and you would be presented with a dialog box to select the jars.
  3. Click on ‘Add External’ button and select the required JAR file.
  4. Click ‘Next’ and fill in the details as per below screenshot —

5. Click ‘Finish’ button.

6. Open ‘Manifest.mf’ file and go to ‘Runtime’ tab and add all the packages to the exported packages.

7. Open ‘Project Explorer’ view and right click on the project you just created and click ‘Export’.

8. Select ‘Deployable plug-ins and fragments’ and click ‘Next’.

9. Select the plugin created above and click ‘Finish’.

Your plugin is ready. But to host the plugin on a p2-repo, you would need additional meta-data e.g. artifacts.jar, content.jar etc. You can follow this article to generate the p2 repo content.

Once you have the 4 things — 1. plugins folder, 2. artifacts.jar, 3. content.jar and 4. category.xml, you can upload these to any cloud location (e.g. Amazon S3) and access the link of the location to use in the ‘active target’ of the application.

Below is an example snapshot of the data which needs to be uploaded to a cloud location.

--

--

Ajay Lamba

Decade of development experience. Passionate for best coding practices.