Tag Archives: pax

Maven Tips and Tricks: Creating an OSGi Project with Maven


September 22, 2009 By Tim O'Brien

This post is a quick start guide to using the Maven PAX plugin to create OSGi project and start an OSGi runtime environment (Apache Felix). First, use the Maven Pax Plugin from OPS4J, and call the create-project goal. The following command-line will create a multi-module project with a groupId of org.sonatype.mhandbook, an artifactId of osgi-project, and a version of 1.0-SNAPSHOT:

~/examples/osgi $ mvn org.ops4j:maven-pax-plugin:create-project \
  -DgroupId=org.sonatype.mhandbook \
  -DartifactId=osgi-project \
  -Dversion=1.0-SNAPSHOT
[INFO] Scanning for projects...
[INFO] artifact org.ops4j:maven-pax-plugin: checking for updates from central
[INFO] Building Maven Default Project
[INFO]    task-segment: [org.ops4j:maven-pax-plugin:create-project] (aggregator
-style)
[INFO] [pax:create-project]
[INFO] Selecting latest archetype release within version range [1,2)
[INFO] artifact org.ops4j.pax.construct:maven-archetype-osgi-project: checking
for updates from central
[INFO] Using following parameters for creating Archetype: maven-archetype-osgi-
project:1.0.3
[INFO] Parameter: packageName, Value: org.sonatype.mhandbook.osgi-project
[INFO] Parameter: archetypeVersion, Value: 1.0.3
[INFO] Parameter: groupId, Value: org.sonatype.mhandbook
[INFO] Parameter: archetypeArtifactId, Value: maven-archetype-osgi-project
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: archetypeGroupId, Value: org.ops4j.pax.construct
[INFO] Parameter: basedir, Value: ~/examples/osgi
[INFO] Parameter: package, Value: org.sonatype.mhandbook.osgi-project
[INFO] Parameter: artifactId, Value: osgi-project
[INFO] ********************* End of debug info from resources from generated POM
[INFO] Archetype created in dir: ~/examples/osgi/osgi-project

Once you’ve generated an OSGi project using the Pax Plugin, you will have the following directory structure:

Continue reading

Introduction to OSGi with Pax, Maven, and Nexus Professional


July 20, 2009 By Tim O'Brien

We’ve released a pre-alpha version of the Maven Cookbook which contains a chapter on OSGi development with Maven via the Pax plugin from OPS4J. This chapter contains a series of recipes which will walk you through the process of creating an OSGi project, importing bundles from both a Maven repository and existing OSGi Bundle Repositories (OBR), and executing an OSGi runtime environment all with the help of the Maven Pax Plugin. The last few chapters provide a road map for developers interested in hosting and combining multiple Maven and OBR repositories into a single repository group with Nexus.

To read the pre-alpha, version 0.1.1 release of the Maven Cookbook, you can: