Eclipse RCP
20.09.2010 - 24.09.2010, Hamburg
git
07.10.2010 - 08.10.2010, Essen
16.04.2010

Building OSGi based applications

I’m just back from the one day workshop “Building OSGi based applications” in Darmstadt, organized by the newly founded OSGi User’s Forum Germany. It was a very interesting day, I learned a lot and want to share my impressions and learnings.

Opening by Andreas Kraft & Jochen Hiller

Andreas Kraft and Jochen Hiller opening the OSGi build workshop
Andreas Kraft (l.) and Jochen Hiller (r.) opening the workshop

Andreas Kraft and Jochen Hiller from Deutsche Telekom AG opened the workshop and welcomed the 50 visitors who were eagerly waiting to learn about all the tools for building OSGi applications.

Andreas told the story of the OSGi User’s Forum Germany which was founded in November 2009. The Forum catered the workshop and strives to represent OSGi in Germany. If you’re interested, follow them on Twitter: OSGiUsers. The workshop was sponsored by Telekom Developer Garden (a “Telekom 2.0” division that provides open APIs for Telekom services) and Seitenbau GmbH (an IT service company from Konstanz).

All presenters were given a demanding challenge: An example web application, written with Spring and OSGi, coming with a web layer in JSF, and a persistence layer utilizing JPA/Hibernate to access an embedded Derby database. The target platform is assembled by Maven. The setup described in this video (in German) runs a Tomcat inside an OSGi container using an IDE launch configuration. You can get the example code from GitHub and hopefully all presenters will make their version of the project available in the next days.

I really liked the overall structure of the workshop; giving all presenters the example as starting point to spin their presentations around provided the audience with means to compare the very different projects.

Eclipse PDE Build, PluginBuilder - Markus Barchfeld

Markus Barchfeld builds with PDE Build and pluginbuilder
Markus Barchfeld builds with PDE Build and pluginbuilder

Markus Barchfeld started the pluginbuilder project years ago to make creating and configuring headless PDE Builds easier. This is achieved by providing IDE tooling to create all the necessary build scripts.

You almost only need to edit pluginbuilder’s .config files, the necessary PDE build files are automatically copied and customized by pluginbuilder according to the configuration. Still, configuring the build for the example application was not an easy task, owed to the fact that the example project was quite ambitious and there were lots of detail issues to solve (like cyclic dependencies in the Spring bundles and trouble around using packages from the com.sun namespace). Still, this effort payed off, Markus was almost the only presenter who demoed the built application running in a web container.

I really appreciate Markus effort for being the first one to step up and making the PDE Build easier to configure. If you want to use a plain PDE build looking for a simplified way to configure it, you should try the pluginbuilder tooling, starting with the pluginbuilder tutorial movie.

Eclipse Buckminster - Achim Demelt

Achim Demelt builds with Eclipse Buckminster
Achim Demelt builds with Eclipse Buckminster

Achim shares the pain many feel about the complexity of configuring PDE Build, commonly referred to as “PDE Build hell”. Using the Buckminster tooling he doesn’t have to cope with the PDE Build hell directly, but sits in the atrium of PDE Build hell, as Buckminster utilizes the PDE Build process internally but makes it a lot easier using concise and meaningful concepts. He became committer to the Buckminster project himself after writing patches and contributing the JUnit test support to Buckminster 1.2, which is to be shipped with the Helios release in June.

The main advantage of Eclipse Buckminster is it’s strict focus on the description of components and the steps necessary to build these components. Internally, all the Eclipse structures like the workspace are reused, so everything that builds in Eclipse also works in Buckminster. Achim demonstrated this in an impressive live demo, where he executed the steps to build the example application manually in Buckminster while starting a regular Eclipse showing how the state of the workspace progressed while the build was performed.

One of the strong points of Buckminster is its seamless integration into the Hudson build server provided by the Buckminster Hudson plug-in. I learned that this plug-in recently was updated to download Buckminster automatically, easing the creation of builds that are distributed across multiple Hudson nodes. Buckminsters weak spot is being “easy to use” - regarding to this somebody asked about tooling to “buckminsterize” existing products; I quickly searched and found an existing bug: Implement Buckminster Project Wizard.

Personally I think Buckminster makes building Eclipse software a lot easier, if you want to try it, start with Eclipse Buckminster, The Definitive Guide by Henrik Lindberg or my tutorial Headless Eclipse RCP builds with Buckminster and Hudson.

Ant4Eclipse - Nils Hartmann, Gerd Wütherich

Nils Hartmann and Gerd Wuetherich build with Ant4Eclipse
Nils Hartmann (l.) and Gerd Wütherich (r.) build with Ant4Eclipse

Nils and Gerd presented their Ant4Eclipse project which provides ant tasks to work with Eclipse projects. Initially it was created to re-use existing project metadata from Eclipse projects by providing tasks like ant4eclipse:getJdtClassPath, but grew to build complete plug-ins in the course of actions.

Remarkably, it doesn’t utilize the PDE Build at all. They kind of reverse engineered the Ant build scripts generated by PDE Build and emulate the behavior of these. Still, the JDT compiler is used so you get the correct behavior when building plug-in projects, for example access restriction errors. For building the example projects, they used the Ant4Eclipse PDE tasks and macros like ant4eclipse:targetPlatform and buildPlugin.

Not using the PDE build comes with some advantages and disadvantages in my opinion. It’s clearly simpler and easier to examine and debug. On the other hand, not all PDE build features are provided and should the PDE build change one day, its emulation in Ant4Eclipse has to change as well. If you’ve chosen Ant as your build tool and want a very approachable way to build your Eclipse projects, Ant4Eclipse is a project to try, ideally by starting with the tutorial My first Ant4Eclipse PDE Build.

Manifest first using ANT - George Mesesan

George Mesesan build with handcrafted Ant tasks
George Mesesan build with handcrafted Ant tasks

George lost a bloody battle against PDE build and decided to take a path similar to Ant4Eclipse. Building mostly embedded applications he wanted full control over the build and sticks to execution flows to describe the steps required to build a project. Ant, Ant-Contrib tasks and hand-crafted Ant tasks written in Java are his tools up to the task. In these tasks he parses the project configuration and manifests and triggers the necessary steps to build. To build the examples, he used such tasks like create-project-list, compute-build-order and build.project. In real-world projects he grooms a set of templates for such builds and customizes these according to the needs of each project. The overall build structure he typically uses is available from the poster “A Complete Continuous Integration System for embedded OSGi Projects”.

If you want a fully customizable and comprehensible build without dependencies to other projects, this might be your path of choice. His example project should provide you with some example tasks to start with and to customize to your needs.

Spring Bundlor - Christian Baranowski

Christian Baranowski builds with Maven and Spring Bundlor
Christian Baranowski builds with Maven and Spring Bundlor

Christian Baranowski, one of the organizers of the workshop, stepped in for Oliver Gierke, who couldn’t make it to the workshop. He demoed the Spring Bundlor tooling which is partially similar to the Bnd tool.

Spring Bundlor comes with Ant tasks, Maven plug-ins and a command line tools. The example project was configured using Maven, starting with a parent pom.xml, accompanied with a pom.xml file in each bundle project. In Eclipse, all the projects are just plain Java Projects with all the referenced libraries on classpath. This is not a Manifest-based approach, the MANIFEST.MF is generated automatically and Import/Export-Package statements are determined by scanning the compiled classfiles for dependencies to other packages. This generation can be customized using a template.mf file which is merged together with the automatically determined headers.

A downside of this is that a Maven build has to be executed when new dependencies are introduced and the manifest needs to be updated. This issue is solved by the free but not-open Spring Tools Suite tooling, which provides incremental generation of the MANIFEST.MF. By the way, the Bundlor tooling will be contributed to the Eclipse Virgo project along with the SpringSource dm Server.

If you’re utilizing Spring and Spring DM for your projects, the Bundlor project is well-worth considering for builds, because it can also analyze Spring’s configuration files for dependencies and works well together with the other Spring tools. Get started with the blog post Getting Started with Bundlor.

PAX - Tools for the OSGi everyday life - Patrick Baumgartner


Patrick Baumgartner uses PAX

Patrick currently kills his time by writing the German book OSGi für Praktiker and by launching a Swiss OSGi user group. He presented the Pax project which provides framework-independent tooling and services around OSGi.

He showed the command line tools provided by Pax Construct and Pax Provision which can used to easily create and deploy bundle projects. The resulting build configuration is solely based on Maven and the maven-bundle-plugin and can be executed without any PAX-specific tooling. Pax Constructs just provides helpers to generate such projects easily. He demoed the pax-create-project and pax-create-bundle commands to setup the projects for the example, producing the project structure for the examples easily.

He also showed the Pax Runner tooling which can be used to boot an OSGi framework. It was impressive to see how simple launching OSGi gets with a little help of pax-run:

pax-run
pax-run --profiles=compendium,web
pax-run --platform=equinox

Unfortunately, the project build could not be created solely by using the Pax tooling, because of issues encountered around Spring-based projects; still it was very interesting and insightful to get a brief overview over the Pax tooling. If you want to make your OSGi everyday life simpler, start with the Pax project pages which also provide instructions for getting started.

Development Workflow mit Maven - Roman Roelofsen

Roman Roelofsen builds with Maven
Roman Roelofsen builds with Maven

Roman Roelofsen showed a build setup based on the Maven Bundle Plugin which internally uses the Bnd tool. This comes with the advantage of being completely independent from any IDE and is similar to projects created by Pax Construct and also similar to the nature of Spring Bundlor projects: the manifest is automatically generated by analyzing the compiled classes.

He showed how this automatically copes with some nasty OSGi corner cases, like having to import every package which is exported and by automatically generating version ranges like [1.1.0, 2.0.0) guarding against API-incompatible version increments. He also demoed how the developer workflow based on such a build can be made more convenient by incrementing using version numbers automatically using a little groovy script using GMaven and the Versions plug-in. Also, his The Bundle Buddy tool can be used to automatically update running bundles whenever they are changed.

If Maven is your build tool of choice and you prefer using the Maven metadata for configuring your projects, the Maven Bundle Plug-in is worth a try for sure. Start with the Bundle Plugin for Maven project page which also provides example code.

Conclusion

It was very insightful to get an overview of almost all the possible solutions for building OSGi projects in one day.

The only point of critique I had was that the Maven Tycho project was missing. There is a lot of hope in the Eclipse community that Tycho will solve the outstanding issue of producing “builds easily” by providing a well-designed bridge between the Maven and the Eclipse world, in particular bridging the currently split world of repository formats. These hopes especially heated up when the project proposed to move over to Eclipse (see the project proposal) some days ago. It would have been great to see Tycho side-to-side with the presented solutions.

A big thank you to the OSGi User’s Forum Germany and the workshop organizers Andreas Kraft, Jochen Hiller and Christian Baranowski!

Jeff McAffer, 16. April, 14:21 Uhr

Darn! Sounds like a very interesting event. Too bad I missed it. It would be great to see the outcome of events like this feed back and influence the folks working on the builders.

Note that Sigil and Ant+Ivy was also missing from the build stories covered.

Antoine Toulme, 16. April, 21:01 Uhr

Tycho ... and Buildr4OSGi :)

Markus Barchfeld, 18. April, 16:21 Uhr

Thanks for this fine summary of the event. In the meantime I have made my homework and a git repository with my changes and screencast is available, see http://www.markusbarchfeld.de/blog/article/2010/04/18/pde_build_for_osgi_applications.html.

Andreas Kraft, 28. April, 09:27 Uhr

Thank you very much for this detailed and in-depth coverage of the workshop! It was a fun event with very good speakers and contributions. We were amazed about the interest. For sure, this was not the last workshop :-)

I'm looking forward to your comments:

Schulungen

Eclipse RCP

Ralf Ebert | Blog | Eclipse RCP | Building OSGi based applications