Fork me on GitHub

Quickstart Guide

This page explains how to use the maven-osgi-distribution-plugin to build OSGi distributions.

Mavenization

At the root of the created project, create a pom.xml file with the following content:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>your.group.id</groupId>
    <artifactId>your.artifact.id</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>myFirstDistribution</name>
    <packaging>osgi-distribution</packaging>
    <repositories>
        <repository>
           <id>typesafe</id>
           <url>http://repo.typesafe.com/typesafe/releases/</url>
        </repository>
    </repositories>

        <dependencies>
               <dependency>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>org.apache.felix.main</artifactId>
                 <version>4.0.3</version>
              </dependency>   
              <!-- Example of distribution bundles-->
              <dependency>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>org.apache.felix.fileinstall</artifactId>
                 <version>3.1.4</version>
              </dependency>
              <dependency>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>org.apache.felix.gogo.command</artifactId>
                 <version>0.12.0</version>
              </dependency>
              <dependency>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>org.apache.felix.gogo.runtime</artifactId>
                 <version>0.10.0</version>
              </dependency>
              <dependency>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>org.apache.felix.gogo.shell</artifactId>
                 <version>0.10.0</version>
              </dependency>
              <dependency>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>org.apache.felix.ipojo.gogo</artifactId>
                 <version>1.10.1</version>
              </dependency>
              <dependency>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>org.apache.felix.ipojo</artifactId>
                 <version>1.10.1</version>
              </dependency>
              <dependency>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>org.apache.felix.log</artifactId>
              </dependency>
              <dependency>
                 <groupId>org.osgi</groupId>
                 <artifactId>org.osgi.compendium</artifactId>
                 <version>4.2.0</version>
              </dependency>
        </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>fr.liglab.adele.common</groupId>
                <artifactId>maven-osgi-distribution-plugin</artifactId>
                <version>1.0.3-SNAPSHOT</version>
                <extensions>true</extensions>
                <configuration>
                    <defaultOutputDirectory>bundle</defaultOutputDirectory>
                    <generateScripts>true</generateScripts>
                    <outputs>
                       <output>
                          <IncludesArtifactId>org.apache.felix.main</IncludesArtifactId>
                          <directory>bin</directory>
                          <outputFileName>felix.jar</outputFileName>
                       </output>
                    </outputs>
                 </configuration>
            </plugin>
      </plugins>
    </build>
</project>

That's it !

Building

In order to build the new distribution, you must execute the following:

mvn clean install

Executing

In the target directory, there is a zip file containing the builded distribution. Also, there are generated scripts start.sh and start.bat to execute the distribution using the temporary files