Background
In my RCP application, I have a project that consists of a plugin and a feature, the setup is like this:
my.plugin/
META-INF/MANIFEST.MF
plugin.xml
src/
my.feature/
feature.xml
The plugin contains unversioned dependencies towards other bundles (in other features). The feature contains versioned dependencies towards other features.
In the end, I will build a RCP application as a feature-based product.
All feature dependencies can be found in a p2 repo hosted by a Nexus server (over HTTP).
Problem
The above can be built fine using Tycho and the manifest-first approach. Tycho picks up the correct target platform based on the versioned feature dependencies.
When developing, I would like to create a target platform given the specified features by reading the feature versions, so that I know that development is being done against a target platform that is compatible with the specified set of features.
What is a good way to create a target platform based on this feature dependency specification? Ideally, I think I would just like to generate the target platform automatically using the latest compatible versions, just like Tycho does.
Related
Several teams in our company use internal framework to build an Eclipse UI. This framework is composed of set of Eclipse plugins.
Our team is responsible for the develpment of this framework and we're looking for some tools that would check API breakage in the further versions of our framework.
For example, we have the following class:
package com.foo.A;
class A {
public void doSmth() {}
}
Currently in MANIFEST we and users of our plugins do not specify any versions of plugin's dependencies (always complining with the latest version).
We'd like to have some warnings from Eclipse if we change something in this class, e.g. change method signature or something else. We'd like Eclipse to suggest us to rise plugin's version in such cases.
I've read the following information about API tooling in Eclipse:
https://wiki.eclipse.org/PDE/API_Tools/User_Guide
But it seems to me that this tooling works only with Eclipse native plugins, but not with our custom developed ones.
If I'm mistaken, could anyone be so kind to explain me how to setup API tooling for our plugins?
the Eclipse API tooling works also with user bundles. What you should do is take your released framework and define it as baseline. A quick solution is to copy all your build and released to the public bundles in a folder and set the folder as Baseline:
Window - Preferences - Plug-in Development - API Baselines - [Add Baseline...]
You can have multiple Baselines if you have to patch older release versions of the framework for example. Be sure to set your API Errors/Warnings as you reqire them.
Edit: Of course you should enable API Tooling in all your bundles as described in "Configure Bundles for API Tooling" in the web page you linked!
I've used the Google Guava library for a half year now inside some small Eclipse RCP applications. Until now it's worked well with the older versions of Guava 11/12 provided inside the Eclipse Orbit p2 repositories.
In a new project I need to use Base64 encoding, but this feature only exists in Guava since version 14, which is not available inside Eclipse orbit.
I know that there is an alternative within the Apache commons, but I want to have minimal dependencies to other bundles.
I also know the bundle itself is OSGi compatible, but the classic RCP build based on features and it is a good practice to define a feature based target platform.
So does somebody know an (official) p2 repository that includes the latest guava version, or do I need to build my own feature based on the library?
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
Manifest-First - which is the standard mechanism for defining a plugin's dependencies
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.
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.
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.
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
The base of our enterprise application is OSGI and we have several Java projects that are logically OSGI bundles. We use Maven to compile the application using the Maven Bundle plugin. But this process is time consuming and makes it impossible to debug the application. We also use the Runner and Pax(:provison) plugins to run the application. If we could rely on the Auto build function of Eclipse and also debug the application it would make our lives so much easier. Is there a way to configure Eclipse to be able to compile (and may be run) an OSGI-based application?
I'm not entirely sure if I understand you, but here goes.
Well, running/debugging OSGi applications in Eclipse is really easy, as long as your bundles reside in PDE aware projects or at least are on your target platform.
Do you have the source of all your bundles? Debugging without source isn't all that useful. If you do, can you just import all the source of your bundles into your Eclipse workspace?
Otherwise you can create a target platform, add all your bundles to that. (as a first attempt, I'd say dump all your bundles in a directory and point the target platform there)
Either way, then you should be able to Run (or debug)-> OSGi framework -> New -> Pick your bundles -> Start
You can both pick bundles from or target platform and from your workspace.
For building, you can use Eclipse Plugin Development Environment (PDE). Despite its name, it isn't specific to building Eclipse plugins and can be used for working on pure OSGi bundles. Eclipse plugins are OSGi bundles with some extras.
Cannot help you with the running or debugging part, although I do know that some enterprise-oriented OSGi platforms provide extensions to PDE.
If you're already using the maven bundle plugin, you may find that PDE's manifest-first approach isn't a good fit with your existing code-first build (I assume at the end you want both an IDE build for development and debugging, and a command-line build for continuous integration and automated testing).
You have two choices. As others have suggested, you can use Eclipse's integrated PDE, and use Tycho for your maven build. Tycho uses the same data used by PDE, so you don't have to write things down more than once. Alternatively, you can stick with the maven bundle plugin and use bndtools within Eclipse. Like the bundle plugin, bndtools is code-first, so you won't need to worry about maintaining manifests. However, you may find there isn't quite as big a set of features in bndtools as in PDE, and I'd suggest still checking your manifests by hand to make sure you understand what's being generated. Whether you prefer manifest-first or code-first is a bit of a heated philosophical debate.
Look at bndtools. bndtools is using the same bnd that is underlying the maven bundle plugin. You can even use bndtools together with m2e. bndtools is available from the Eclipse market place.
The eclipse plugin development environment is a pretty handy tool when creating from scratch a set of OSGi bundles that need to work together. Particularly this is true when trying to get all the package imports and exports and other manifest fluff right during development, or if there are third party jars that need to be embedded. But trying to retrofit a maven build process around this afterwards seems to be pretty tricky, mainly because most of the maven plugins for bundling/OSGi build the manifest themselves, whereas using the PDE, you are handcrafting the manifest.
What is the best way to retrofit a maven build process to a bunde/set of bundles, that dont respect the standard maven project layout, and already have handcrafted manifests?
Use Tycho. It lacks some documentation, but it does just that: builds the plugins using the PDE semantics (actually, it uses PDE compiler internally). So, all you need is to create almost empty pom.xml's for your modules.