mbarchfe edited this page Sep 14, 2010 · 20 revisions
Clone this wiki locally


This example is based on Christian’s OSGi sample application, which was used in the OSGi Workshop as a reference. This fork includes everything that is needed to build the application from command line ANT with the PDE Build and pluginbuilder. The main changes of this fork compared to the original repository are

  • Added features which are a prerequisite for the PDE Build
  • Fixed build.properties in the bundles
  • Added HTTP Unit for integration tests since the tests provided in the example are not “OSGi ready”, i.e. they do not run if installed as bundle
  • added Pluginbuilder project

There is also a screencast on how to set up the build with a new Pluginbuilder project.

Let’s get started with downloading and extracting the example from github, http://github.com/mbarchfe/osgi-kasse-example. You can either check it out with git or download a zip file.

In the following it is assumed that the example has been extracted to ${example.home}

Getting all the dependent bundles

It is not part of this build to fetch the dependent bundles, so we prepare a directory with all the bundles and the Eclipse installation needed to run the PDE Build beforehand.

Christian has prepared a pom.xml which retrieves the target platform via maven. For this build we want to install the application after the build into an Eclipse test host for running integration tests. Therefore we remove the org.eclipse.* bundles from Christians target platform and let the build pick these bundles from the Eclipse tests host instead. Otherwise we run into version conflicts. In addition we need the delta-pack for creating a native launcher.

$ cd ${example.home}/osgi-plattform
$ mvn package
$ rm target/org.eclipse.*
$ unzip eclipse-3.5.2-delta-pack.zip -d eclipse-3.5.2-delta-pack
$ tar xzf eclipse-SDK-3.5.2-macosx-cocoa-x86_64.tar.gz

Run the build from Eclipse

Of course you want to set up a headless build to run on a server probably within a continuous integration tool. Here I explain how to run the build from Eclipse because the idea of pluginbuilder is to set up and debug the build in an Eclipse workspace which contains the plug-ins and features of the application to be built.

Christian has created a video how to set up an Eclipse workspace with the example. You can follow his description and then add the eclipse directory to the target platform as follows

  • ${example.home}/osgi-plattform/target
  • ${example.home}/osgi-plattform/eclipse/eclipse

In order to tweak the map file with a text editor or alternatively you can install pluginbuilder and let it do the work, http://self.pluginbuilder.org/nightly/p2-updateSite.

  • double click org.osgiusers.germany.example.kasse.pluginbuilder/pluginbuilder.config opens the Pluginbuilder editor
  • click “Generate Build Files” to update your map file
  • go to the local tab and set bundleHome to ${example.home}/osgi-plattform, double check the build directory
  • if on windows, switch to the Properties tab and separate the entries in pluginPath with semicolon instead of colon
  • go to the RCP tab and choose the platform for which to create native launchers
  • on the Tests tab double check the test.eclipse.host property
  • return to the main tab, press “Build Head” and confirm the change of buildHome

Now wait and pray. The build takes about 10 minutes on my laptop. To see the build results go to ${buildDirectory}/results where you will find

  • the executables for the platforms chosen above
  • test and coverage results

Run the build from command line

The PDE build can be started from the command line via ANT and can therefore be run on any server. To bootstrap the build just check out the org.osgiusers.germany.example.kasse.pluginbuilder and run ant in that folder. All local dependencies should be set up in build_local.properties file. For any build-server you can create a file with the specific settings for that server.

For this example however there is an additional step necessary: PDE build can only “natively” fetch sources from CVS or Subversion. One way to add arbitrary VCS is to check out/export your code from the VCS into a local directory and then then copy the sources from that place into the build directory. PDE supports this with the COPY method in map files.

I have used this approach in the example and therefore you must take care that the local directory where the sources reside is available on the server, too.