Best practice is to define the version of the OSGi distribution plugin that you want to use in either your pom.xml or a parent pom.xml.
<project>
[...]
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>fr.liglab.adele.common</groupId>
<artifactId>maven-osgi-distribution-plugin</artifactId>
<version>1.0.3-SNAPSHOT</version>
</plugin>
</plugins>
</pluginManagement>
</build>
[...]
</project>
To use the maven-osgi-distribution-plugin Plugin, you need to add the following configuration to your pom.xml
<project>
[...]
<packaging>osgi-distribution</packaging>
[...]
<build>
<plugins>
<plugin>
<groupId>fr.liglab.adele.common</groupId>
<artifactId>maven-osgi-distribution-plugin</artifactId>
<version>1.0.3-SNAPSHOT</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
[...]
</project>
The maven-osgi-distribution-plugin Plugin is invoked during the:
A full run, executing all the above steps:
mvn clean install
Plugin configuration options:
outputs section. Default value load.false.false.An output configuration example :
<outputs>
<output>
<IncludesArtifactId>org.apache.felix.main</IncludesArtifactId>
<directory>bin</directory>
<outputFileName>felix.jar</outputFileName>
</output>
<output>
<IncludesArtifactId>org.apache.felix.fileinstall</IncludesArtifactId>
<directory>bundles</directory>
</output>
</outputs>
Results in the following :
Projects using this plugin need to use the "osgi-distribution" packaging type, and call the plugin in their plugins section.
<build>
<plugins>
<plugin>
<groupId>fr.liglab.adele.common</groupId>
<artifactId>maven-osgi-distribution-plugin</artifactId>
<version>@project.version@</version>
<extensions>true</extensions>
<configuration>
<defaultOutputDirectory>bundle</defaultOutputDirectory>
<generateScripts>true</generateScripts>
<outputs>
...
</outputs>
</configuration>
</plugin>
</plugins>
</build>
To run the plugin, just call the "install" goal on your project.
By default the plugin copy all deployment packages defined as project dependencies. If you prefer not to rely on deployment packages, you can ask to flatten all deployment packages using flattenDP configuration option:
<project>
[...]
<packaging>osgi-distribution</packaging>
[...]
<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>
<flattenDP>true</flattenDP>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
You can set additional files to be appended to the OSGi distribution zip file. You only need to put them into the src/main/resources folder. Relative path to copied resources is preserved into the zip file.