6

I want to add some GitHub projects as dependencies to my Eclipse RCP Plugin. The GitHub projects are oshi and leshan.

Both GitHub projects provide maven builds over maven central which i could use.

But as i understand so far i cant use these builds directly in an Eclipse RCP Plugin because it requires OSGI-Bundles - in contrast to an "classic" Eclipse Java project.

So far i found three ways of dealing with this problem:

I also looked into Tycho but as far as i understand you can only add a p2 repository as a dependency in Tycho, which leads again to the problem of creating one.

Is there another/better way of dealing with Non-OSGI-Bundle Maven builds in an Eclipse RCP Plugin?

EDIT: i found for me the best way to use gradle (a gradle plugin bnd-platform), to automatically resolve the dependencies using maven central and create a local p2 repository, described in Option 1 here https://stackoverflow.com/a/29509794/12029492

J0n8s
  • 61
  • 3
  • No, there is no better way. In Maven modules/bundles are resolved on compile/build time whereas in OSGi bundles can be started and stopped at run time. For this in OSGi a JAR must contain additional metadata and a p2 repository must contain metadata to resolve also imported packages. So you first have to convert the JAR into a OSGi bundle (or ask the vendor of the JAR to do this) and then create a local p2 repository via [Tycho `tycho-p2-extras:publish-features-and-bundles`](https://www.eclipse.org/tycho/sitedocs-extras/tycho-p2-extras-plugin/publish-features-and-bundles-mojo.html). – howlger Sep 06 '19 at 12:02
  • Thanks for making it clear to me – J0n8s Sep 06 '19 at 14:13
  • I'm the lead maintainer of OSHI. I thought we were already publishing OSGi bundles via the `bnd-maven-plugin`. Am I mistaken? Is there something I need to configure? – Daniel Widdis Sep 12 '19 at 21:01
  • Yeah your right, looks like OSHI is already a OSGi bundle. Sorry for the inconvenience. – J0n8s Sep 15 '19 at 08:57

1 Answers1

6

Recently the Eclipse Maven (M2E) implemented tight integration of Java libraries from Maven central into the target platform. With this, you can easily add Java libraries to your target platform and they can be converted (if necessary) on the fly to OSGi bundles including their dependencies.

See https://www.vogella.com/tutorials/EclipseJarToPlugin/article.html for how to using Java libraries (from Maven Central) for OSGi, Eclipse Plug-in and Eclipse RCP development.

This extension is also supported with the latest Maven Tycho version for command line builds, see https://www.vogella.com/tutorials/EclipseTycho/article.html

vogella
  • 24,574
  • 4
  • 29
  • 26