Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Maven to build OSGi application

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?

like image 866
Jeewantha Avatar asked Mar 31 '13 12:03

Jeewantha


3 Answers

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.

like image 134
Florian Albrecht Avatar answered Nov 16 '22 19:11

Florian Albrecht


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>  
like image 11
Dmytro Pishchukhin Avatar answered Nov 16 '22 20:11

Dmytro Pishchukhin


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

like image 4
Balazs Zsoldos Avatar answered Nov 16 '22 21:11

Balazs Zsoldos