I have a set of OSGi bundles being built using Maven and I was wondering if there is a Maven plugin available that allows me to do the following:
- Specify the set of bundles to include in a distribution and/or specify a single bundle and have the dependencies resolved.
- Build a complete distribution of the framework. What I mean is a single zip file containing all the bundles needed, plus the correct directory structure for felix so that the user can simply unzip the file and type "java -jar bin/felix.jar".
I did some Googling and I didn't find anything very promising aside from appassembler. Have any of you ever come up with a good solution?
Update
Here's an illustration of what I'm trying to accomplish.
example-parent\
bundle-one
bundle-two
bundle-three
assembly-one
assembly-two
Where assembly-one
would include bundle-one
and bundle-two
and assembly-two
would include bundle-two
and bundle-three
or any combination thereof. Then when you build your project, you would get two zip files, one for assembly-one
and one for assembly-two
that would contain the appropriate bundles in a self-contained felix install. For example:
assembly-one.zip\
bin\felix.jar
bundle\bundle-one, bundle-two, plus bare min felix bundles
conf\any configuration files I need
Hopefully that provides a little more information about what I'm trying to accomplish. I guess this is kind of similar to how Eclipse does a feature.xml, but of course not using Eclipse.
Fred's suggestion of using the assembly plugin to package up a self-contained distribution which can be zipped up is a good one. If you're looking for an example of how the build files for this would work, the Apache Aries blog sample source uses the maven bundle and assembly plugins.
Another approach is to create application artifacts. There isn't a single OSGi standard for this (yet), but several projects provide a way of grouping bundles together into super-bundles. This isn't quite like what you describe with your assemblies, since the OSGi framework isn't included, but it's similar to Eclipse feature.xmls. Have a look at Apache Aries eba (enterprise bundle archive) applications, Virgo plan files, or Karaf features. In most of these bundlings you get an archive which includes some bundles, and/or a metadata file which describes the application contents. Bundles which aren't included in the archive can be provisioned from a repository. For Aries, there is also an eba maven packaging which will generate the .eba archive containing the APPLICATION.MF file and included bundles.
We've got a bit more on this in Chapter 4 of Enterprise OSGi in Action (http://www.manning.com/enterpriseosgiinaction),or a quick google for eba, Virgo plan, or karaf feature should find you lots more. The downside for your use case is that the applications would need to be deployed into a runtime with the appropriate technology pre-installed into it, since none are core OSGi.
Another project to look at to make deploying easier is Felix file install. This allows you to drop bundles into a monitored directory, which saves having to write configuration files.
The Sling Launchpad Plugin [1] creates a runnable jar file or a war file that embeds the OSGi framework and a customizable list of bundles, that's probably what you need. With that you don't even have to unpack the generated jar file, just starting it is sufficient.
[1] http://sling.apache.org/site/maven-launchpad-plugin.html
Perhaps this can help for what you're trying to accomplish?
I don't know for sure but maybe it's worth a shot?
http://maven.apache.org/plugins/maven-assembly-plugin/
Also perhaps the following?:
http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
It will require a bit of reading/research but I think it might be useful. If not then maybe I don't correctly understand your goal and I am sorry.
If you are using OSGi v4+ and building with Maven, use pax-ops4j. It is very convenient to use and makes OSGi development a breeze.