felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bennett <timo...@exterminator-x.com>
Subject [ANN] OSGi archetype for Maven2
Date Mon, 02 Jan 2006 00:04:22 GMT
Folks,

I've created a Maven2 archetype for creating mavenized OSGi bundle 
projects quickly.  An archetype is a very simple plugin, that contains 
the project prototype you wish to create.  Upon executing the OSGi 
archetype, maven will automatically create:

* a project directory structure
* a maven POM for building your bundle (which includes reference to the 
maven-osgi-plugin and the osgi.jar)
* a simple bundle activator java class to kickstart your bundle development

Using a Maven2 archetype is a great way for Maven newbies to get 
productive quickly using the maven build system.

Pre-Requisites
==========
As a pre-requisite for using the OSGi archetype, you'll need to (1) 
install Maven2, (2) install the maven-osgi-plugin, and (3) add the 
Safehaus Maven2 repository to your Maven2 settings.  A how-to for all 
three of these pre-reqs can be found at [1].

How-To
======
To use the OSGi archetype to kickstart your next OSGi/Maven2 bundle 
development project, perform the following steps (after performing the 
above 3 steps):

(1) fetch the osgi-archetype project from the Felix repo at [2]

(2) install the osgi-archetype plugin by executing the following from 
the root of the osgi-archetype directory:

mvn clean install

(3) navigate to the directory where you wish to create your new OSGi 
bundle project and execute the following:

mvn archetype:create -DarchetypeGroupId=org.apache.felix.archetypes 
-DarchetypeArtifactId=osgi-archetype -DarchetypeVersion=1.0 
-DgroupId=<your project group ID> -DartifactId=<your project artifact ID>

(4) navigate to the subdirectory just created (named after your 
artifactId specified), and execute the following to build your OSGi bundle:

mvn package

(5) navigate to the subdirectory named 'target' and you'll see the your 
bundle jar (named after the artifactId specified).  deploy this to your 
OSGi container such as Oscar (or Felix).  A working bundle out of the box!

(6) Modify the Activator code, add your additional bundle classes, and 
modify the POM to customize the manifest entries to complete your bundle 
development.

A Few Notes
=========
Your project group ID should be something like a namespace identifier, 
e.g. gov.nashville.jis or org.apache.directory.  Maven will use this 
group ID as a package naming structure for your bundle code.

Your artifact ID should reflect the name of your project or bundle, e.g. 
echo-server or http-service or jabber-server.  Maven will use this 
artifact ID to construct the name of your bundle jar (unless you 
override it in the POM) and the root name of the project directory.

Refer to [1] for instructions on how to the customize the POM for 
manipulating the OSGi bundle manifest.  Refer to [3] for documentation 
on how to customize the POM for using maven for other build tasks 
(including dependency management).

I'll try to get these instructions up on the OSGi Wiki at Safehaus soon 
in hopefully a more instructive format than this email.

References
=======
[1] http://docs.safehaus.org/display/OSGI/OSGi+Plugin+for+Maven+2.0
[2] 
https://svn.apache.org/repos/asf/incubator/felix/trunk/tools/maven2/osgi-archetype 

[3] http://maven.apache.org/guides/index.html

Mime
View raw message