Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good way to "wrap" jars for OSGi with Maven

Tags:

java

maven

osgi

I was looking at the PAX tools on OPS4J for example: this one and I thought I'd found a nice way to:

  • Specify an artifact
  • Create an assembled jar (jar that contains all dependencies) from that jar and its transitive dependencies
  • Wrap it with BND to create an OSGi bundle

It turns out, that I was wrong - it doesn't appear that the PAX stuff does this. (RTFM, right? :) )

But this got me wondering: is there something out there that does what I'm asking?

I've thought maybe I could do this by creating a simple POM and using the maven-bundle-plugin but this seems like it might be a bit cumbersome for what I'm asking.

NOTE: I get that embedding and assembling jar's is not really "the OSGi way" - so I wouldn't do this unless I really felt it useful. For example - Spring.

Thanks in advance.

like image 320
javamonkey79 Avatar asked Dec 30 '10 18:12

javamonkey79


1 Answers

I wrote a maven archetype that will help you wrap a jar as an OSGI bundle.

Let's say you want to wrap commons-collections version 3.2.1

First get the archetype and install it

git clone git://github.com/HallwayTech/maven-wrap-jar-archetype.git 
cd maven-wrap-jar-archetype
maven install

Then use the archetype to start your project.

mvn archetype:create \
  -DarchetypeGroupId=com.hallwaytech.osgi \
  -DarchetypeArtifactId=wrap-jar \
  -DarchetypeVersion=1.0-SNAPSHOT \
  -DgroupId=commons-collections \
  -DartifactId=commons-collections \
  -Dversion=3.2.1

cd commons-collections

mvn install

To deploy to a Apache Sling inside of Felix run:

mvn install -Pdeploy
like image 189
Erik Froese Avatar answered Sep 18 '22 03:09

Erik Froese