Use Maven to build OSGi application
Asked Answered
V

3

10

I want to build an OSGi compliant multi-moduled application where I have all the required bundles in 3 folders after compilation. I am using maven-bundle-plugin and maven-scr-plugin to create the bundles.

What I want is to run this application in an osgi container (Equinox) with a single command, using a script hopefully. For this I believe I have to create a config.ini file listing all the bundles in the application.

Is there a way to generate this at Maven compilation time itself? Or is there a better way to get all the bundles in some folder structure so that the app can be run straight away?

Vandiver answered 31/3, 2013 at 12:3 Comment(1)
If this is only for development, you could use Pax Construct (ops4j1.jira.com/wiki/display/paxconstruct/Pax+Construct) which is PaxRunner and some other goodies for Maven.Crowl
M
4

Just have a look at Tycho and its different packaging types (e.g. eclipse-application).

http://www.eclipse.org/tycho/

http://wiki.eclipse.org/Tycho/Packaging_Types

It is used for many commercial and open source applications.

Muster answered 2/4, 2013 at 7:22 Comment(0)
D
11

You can use maven-pax-plugin with PaxRunner in your OSGi Maven project. Check this tutorial for the details.

<plugin>  
 <!-- Pax Runner Maven plugin -->  
 <groupId>org.ops4j</groupId>  
 <artifactId>maven-pax-plugin</artifactId>  
 <version>1.4</version>  
 <configuration>  
       <!-- Pax Runner version -->  
       <runner>1.4.0</runner>  
       <!-- OSGi framework type (equinox, felix, knopflerfish) -->  
       <framework>equinox</framework>  
       <provision>  
             <param>--log=debug</param>  
             <param>--workingDirectory=target/runner</param>  
             <!-- bundles that should be installed -->  
             <param>mvn:org.osgi/org.osgi.compendium/4.1.0@2</param>  
             <param>mvn:org.apache.felix/org.apache.felix.eventadmin/1.2.2@3</param>  
             <param>mvn:org.apache.felix/org.apache.felix.log/1.0.0@3</param>  
       </provision>  
 </configuration>  
</plugin>  
Dryclean answered 2/4, 2013 at 6:12 Comment(1)
Is it possible to have multiple configurations, i.e. one for felix, and one for equinox? I tried setting the framework via maven property, but felix and equinox have different dependencies (e.g. for declarative services).Mongolia
S
4

I wrote a maven plugin that by default creates a dist folder under target that contains a ready-to-use equinox with all maven dependencies. Equinox is wrapped with YAJSW so you can use the generated equinox package as a test server. Please see the plugin usage page: http://www.everit.org/eosgi-maven-plugin/

The documentation is a bit poor yet so in case you have any question please do not hesitate to ask.

A short step-by-step guide:

  • Check out https://github.com/everit-org/osgi-samples-simple (user:guest, pass: guest)
  • Run "mvn install". This will generate a testing equinox environment at target/eosgi-itests-dist/equinox in the module tests/core.
  • In case you want to have a simple equinox server without the testing modules you can run the command "mvn eosgi:dist" on the tests/core module.

Edit:

A new cookbook will be available soon that contains a much more detailed step-by-step guide. The url is http://cookbook.everit.org

Spalato answered 1/4, 2013 at 19:13 Comment(0)
M
4

Just have a look at Tycho and its different packaging types (e.g. eclipse-application).

http://www.eclipse.org/tycho/

http://wiki.eclipse.org/Tycho/Packaging_Types

It is used for many commercial and open source applications.

Muster answered 2/4, 2013 at 7:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.