0

I am currently deploying maven managed bundles into the felix framework and I want to create a maven project for the deployment process and want to automate all the process using maven plugins.

Using maven-dependency-plugin we can somehow automate the deployment process.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.8</version>
     <executions>
         <execution>
             <id>unpack-felix</id>
             <phase>compile</phase>
             <goals>
                 <goal>unpack-dependencies</goal>
             </goals>
             <configuration>
                 <includeArtifactIds>org.apache.felix.ipojo.distribution.quickstart</includeArtifactIds>
                 <outputDirectory>${project.build.directory}/tmp</outputDirectory>
             </configuration>
         </execution>
         <execution>
             <id>copy-bundles</id>
             <phase>package</phase>
             <goals>
                 <goal>copy-dependencies</goal>
             </goals>
             <configuration>
                 <includeArtifactIds>
                     sample.maven.bundle1,
                     sample.maven.bundle2,
                     .
                     .
                     sample.maven.bundleN
                 </includeArtifactIds>
                 <outputDirectory>${project.build.directory}/bundle</outputDirectory>
             </configuration>
         </execution>
     </executions>
</plugin>

But all the bundles mentioned in the <includeArtifactIds> will be static and we might have problems updating them using bundle:update or felix:update.

How can I deploy the bundles into felix or karaf the same as running felix:deploy inside felix but called using maven instead ?

megamoth
  • 695
  • 2
  • 12
  • 27

1 Answers1

0

Not sure I fully understand your requirements, but for Karaf you have feature descriptors. Basically an xml file that tells the feature resolver which bundles are to be installed together and or which other features might be needed as prerequisite.

For example the following feature.xml:

<?xml version="1.0" encoding="UTF-8"?>
<features name="myfeature" xmlns="http://karaf.apache.org/xmlns/features/v1.0.0">

    <repository>mvn:org.apache.camel.karaf/apache-camel/2.15.0/xml/features</repository>

    <feature name='myfeature' version="1.0">
        <bundle>mvn:my.group.id/sample.maven.bundle1/1.0</bundle>
        <bundle>mvn:my.group.id/sample.maven.bundle2/1.0</bundle>
        <bundle>mvn:my.group.id/sample.maven.bundle3/1.0</bundle>
        <bundle>mvn:my.group.id/sample.maven.bundle4/1.0</bundle>
        ...
        <bundle>mvn:my.group.id/sample.maven.bundleN/1.0</bundle>            
    </feature> 

...
</features>

features are easily deployed in Karaf with:

feature:install myfeature

while installing a single bundle is as easy with the correct mvn coordinate:

bundle:install mvn:my.group.id/sample.maven.bundle1/1.0

If you just want to have this in your own container, you'll need to add the pax-url-aether project to your setup, it adds the require mvn-Url handler. With this url-handler it's possible to install bundles from mvn-coordinates.

EDIT:

Another way of having all this provisioned in one go is, use the karaf-maven-plugin for creating a custom distribution.

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">

<artifactId>Karaf-Service-Runtime</artifactId>
<packaging>karaf-assembly</packaging>

...

    <plugin>
        <groupId>org.apache.karaf.tooling</groupId>
        <artifactId>karaf-maven-plugin</artifactId>
        <version>${karaf.version}</version>
        <extensions>true</extensions>
        <configuration>
                <!-- <startupFeatures/> -->
                <bootFeatures>
                    <feature>standard</feature>
                    <feature>management</feature>
                    <feature>war</feature>
                    <feature>my-feature</feature>
                </bootFeatures>
                <!-- <installedFeatures/> -->
            </configuration>
    </plugin>

Another way of doing, is to use something I created for a showcase (requires Karaf 4.0.0, which is currently available as SNAPSHOT). Make sure your custom distribution contains the jolokia feature, and install your feature with a rest request sent from a maven plugin. Might want to take a look at my showcase.

Achim Nierbeck
  • 5,265
  • 2
  • 14
  • 22
  • you got it halfway by using features to install bundles in karaf but will still need human interaction by typing `feature:install myfeature` in karaf, what I want is to eliminate human interaction and do all the commands using maven with just simple `mvn clean install` or `mvn clean deploy` but you can still edit your answer and I hope you can help me :) – megamoth May 04 '15 at 10:53
  • I found your email regarding custom distribution using `karaf 4.0.0.M2` and I can't still make it run the right way even with the answer, removing `standard` and manually add the features you like. – megamoth May 05 '15 at 17:52