The initial project and a frame

So the first thing I want to do is to start the OSGI platform and display my main frame.

First I need to create a project for my first bundle. Setting up the project is not so easy as I expected it. One thing I want to use is Maven for building and packaging the bundle. Why? Because I want to! No, using Eclipse makes it very easy because it comes with PDE and some wizards to create an OSGI conform project. The problem is that I want to use continous integration and all other fancy stuff I’m used to in my daily developer life. I know it is also possible with Eclipse PDE but then I would also need all the supplemental scripts Eclipse is using for their build infrastructure. I have no glue how they work, so this can also be interesting🙂 . But this time I have to ignore there’s just not enough time. So back to Maven. The basic POM file is created just easily by copying it from some other projects.

The changes I had to make are listed below:

...
<packaging>bundle</packaging>
...
<dependency>
  <groupid>org.apache.felix</groupid>
  <artifactid>org.osgi.core</artifactid>
  <version>1.0.0</version>
  <scope>provided</scope>
</dependency>
...
<build>
<plugins>
...
<plugin>
  <groupid>org.apache.felix</groupid>
  <artifactid>maven-bundle-plugin</artifactid>
  <version>1.1.0-SNAPSHOT</version>
  <extensions>true</extensions>
  <configuration>
    <instructions>
      <bundle-symbolicname>${pom.artifactId}</bundle-symbolicname>
      <bundle-name>${pom.name}</bundle-name>
      <bundle-vendor>Daniel Rohe</bundle-vendor>
      <bundle-activator>net.sf.daro.application.ApplicationActivator</bundle-activator>
      <export-package>net.sf.daro.application</export-package>
    </instructions>
  </configuration>
</plugin>
...
</plugins>
</build>
...

The packaging needs to be „bundle“ and I need to add a dependency to the OSGI framework. Who would have guessed! Beside that the only big change is in the build’s plugins section. There the maven-bundle-plugin has to be added and configured. But I think everything is straight forward. Having this configuration ready brings me up to work. But there is one thing missing! The maven-bundle-plugin is a snapshot version, so I have to include the snapshot repository.

...
<pluginrepositories>
<!-- repository required for building OSGI bundles using Maven 2.0 -->
<pluginrepository>
  <id>apache.snapshots</id>
  <name>snapshot plugins</name>
  <url>http://people.apache.org/repo/m2-snapshot-repository</url>
  <releases><enabled>false</enabled></releases>
  <snapshots><enabled>true</enabled></snapshots>
</pluginrepository>
</pluginrepositories>
...

That’s all. After adding all this to the basic POM file and running mvn eclipse:eclipse brought me up to start working on code in my favorite IDE.

Schlagwörter: , , ,

Schreibe einen Kommentar

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s

%d Bloggern gefällt das: