Developing eclipse plugin using maven dependencies
Asked Answered
C

3

6

I've been beating my head against a wall for about 6 months now and have not found a concise way of understanding the mechanism for developing an eclipse plugin with third-party resources.

We are attempting to develop an Eclipse ODA to ride on top of in-house Spring-based code that accesses a REST based info set.

In broad strokes - this is what I feel that we need to be able to do:

  • Augment our maven artifacts with Eclipse bundle information using tycho or a the felix bundle plugin.
  • Set up a plugin project through Eclipse for the ODA Implementation & UI.
  • Have Tycho generate the poms etc for the plugin.

Now here's where I get muddy. I understand that there are two approaches

  1. Manifest-First - which is the standard mechanism for defining a plugin's dependencies
  2. POM-First - which provides dependencies via Maven's resolution mechanisms.

I'm not entirely sure where to begin trying to start doing this as I've never worked on developing an eclipse plugin.

One of the other questions I have is, how does a developer of an eclipse plugin (maven aside) leverage already existing third-party code (i.e. Apache HttpClient 4.x)? Do they have to download the jars, dump them into a directory within the project, add to classpath, then go from there or is there a "repository" mechanism similar to what is used with ivy, maven, gradle?

Thanks in advance and I apologize if I was rambling a bit with that.

Claudell answered 29/5, 2013 at 15:21 Comment(0)
M
3

The best way for an Eclipse plugin to consume libraries is as OSGi bundles. You just install those bundles into your target platform and reference them in the same way as eclipse.org plugins. Some of the library providers already offer their libraries as OSGi bundles. Absent that, you can typically turn a plain library jar into an OSGi bundle simply by adding a few manifest entries.

Depending on the build system you use and whether the libraries you need are available as OSGi bundles packaged into an online p2 repository, you can reference the URL and rely on your build to download and install the bundle.

Midsummer answered 29/5, 2013 at 17:43 Comment(6)
thanks for the tip! Now - for my sanity - and this may be PAINFULLY obvious - how does one install an OSGi bundle? Can they be referenced from a remote location by URL?Claudell
Bundles are published in what's called a "p2 repository". The p2 system provides provisioning of bundles into Eclipse environment. Look for artifacts.jar and content.jar to see if a URL is a p2 repository. If you have a bundle but not a p2 repository, various build systems have means to synthesize a local repository to install from.Midsummer
You should really pick a build system before exploring this area further. A lot of the answers are dependent on where you go. The Maven/Tycho approach has a large community to reach out to for support. It is also compatible with Eclipse Plugin Development Environment (PDE), since it is manifest first.Midsummer
Thanks again for your response. Sorry if I was not clear on this. My intent is to continue to utilize maven for our builds. Obviously, the plugin would be developed through eclipse, but I would like to leverage our existing libraries and its dependencies to provide the operation framework on which the plugin executes.Claudell
To develop plugin using PDE, you have to use manifest first approach, which puts you in Maven/Tycho territory. You'd still be using Maven, but not in the same way for a plain Java app.Midsummer
That I do understand. thanks again for your input and response!Claudell
C
4

Disclaimer: Your question is very broad, so it is impossible to answer it completely. Still, I can give you some hints so that you know what to search for.

In the Eclipse universe, the primary source for libraries (in the sense of binary dependencies) are p2 repositories. However, since p2 repositories are rarely used outside of the Eclipse context, you won't e.g. find a p2 repository on the Apache HTTP Client project's download page.

To account for this problem, there is the Eclipse Orbit Project which provides libraries used by Eclipse projects in p2 repositories.

If you can't find the library or library version in the Eclipse Orbit, you may also be able to use the libraries from Maven repositories. This is for example supported by Tycho via the pomDependencies=consider mechanism.

Note however that Eclipse plug-ins can only depend on libraries which are OSGi bundles. So if the library in the Maven repository is not yet an OSGi bundle, you need to convert it to an OSGi bundle first, e.g. with the maven-bundle-plugin and the Embed-Dependency mechanism.

Civilian answered 9/5, 2014 at 21:26 Comment(0)
M
3

The best way for an Eclipse plugin to consume libraries is as OSGi bundles. You just install those bundles into your target platform and reference them in the same way as eclipse.org plugins. Some of the library providers already offer their libraries as OSGi bundles. Absent that, you can typically turn a plain library jar into an OSGi bundle simply by adding a few manifest entries.

Depending on the build system you use and whether the libraries you need are available as OSGi bundles packaged into an online p2 repository, you can reference the URL and rely on your build to download and install the bundle.

Midsummer answered 29/5, 2013 at 17:43 Comment(6)
thanks for the tip! Now - for my sanity - and this may be PAINFULLY obvious - how does one install an OSGi bundle? Can they be referenced from a remote location by URL?Claudell
Bundles are published in what's called a "p2 repository". The p2 system provides provisioning of bundles into Eclipse environment. Look for artifacts.jar and content.jar to see if a URL is a p2 repository. If you have a bundle but not a p2 repository, various build systems have means to synthesize a local repository to install from.Midsummer
You should really pick a build system before exploring this area further. A lot of the answers are dependent on where you go. The Maven/Tycho approach has a large community to reach out to for support. It is also compatible with Eclipse Plugin Development Environment (PDE), since it is manifest first.Midsummer
Thanks again for your response. Sorry if I was not clear on this. My intent is to continue to utilize maven for our builds. Obviously, the plugin would be developed through eclipse, but I would like to leverage our existing libraries and its dependencies to provide the operation framework on which the plugin executes.Claudell
To develop plugin using PDE, you have to use manifest first approach, which puts you in Maven/Tycho territory. You'd still be using Maven, but not in the same way for a plain Java app.Midsummer
That I do understand. thanks again for your input and response!Claudell
D
2

If question of choosing a build system for Eclipse plugins with dependencies is still relevant:

Today I released new gradle plugin: Wuff version 0.0.1, which (I think) completely solves the problem. It allows to build Eclipse bundles and applications as they would be "normal" Gradle projects. All OSGi woodoo is auto-generated (although customizable). All dependencies are usual maven dependencies - regardless of whether dependency is OSGi or "normal" library.

Sources and doc: https://github.com/akhikhl/wuff

Dryer answered 5/5, 2014 at 15:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.