27
Jun

Release an OSGI Bundle into an OBR with Maven

Comments Off on Release an OSGI Bundle into an OBR with Maven

I’ve been investigating lately what to do with a bundle, once it’s released:

  1. Should I automatically deploy it into a Staging or Production server ?
  2. Should I deploy it into another repository and then use Felix Web Console to deploy it manually ?

Automation is always good, but in conditions where before reaching Production there is a Staging / Pre-production environment, the #1 option doesn’t seem to fit. Therefore I’ve been looking on solutions for #2.

The idea that attracted me the most was to use an OBR ( OSGI Bundle Repository ). Felix Web Console has already an OSGI Repository section, which can connect to a remote OBR and let admin users install OSGI bundles right from the administration page.

I’m going to describe what I’ve done in order to achieve this.

  1. Create an empty OBR.

    For this I configured a new subdomain : obr.mydomain.com, in one of my development machines. I’ve linked the subdomain to

    /var/www/html/obr

    In that folder I’ve created an empty repository.xml file

    vi repository.xml
    <repository name='MediaCenter Bundle Repository'>
    </repository>

    I’ve then checked that I can open the XML file from the browser:

    http://obr.mydomain.com/repository.xml
  2. Configure Maven to deploy the bundle into the OBR, during a Maven Release.
    mvn -Dresume=false release:prepare release:perform \
       -Darguments="-DremoteOBR=my-obr \ 
                -DobrDeploymentRepository=my-obr::default::file:///var/www/html/obr/ \
                -DprefixUrl=http://nexus.mydomain.com/nexus/content/repositories/releases"

    If you’ve performed a maven release before, release:prepare and release:perform should be familiar to you. I’ll explain the other options.

    • -DremoteOBR – it’s an ID I gave to the OBR repository.
    • -DobrDeploymentRepository – defines the OBR repository: OBR_ID::layout::url .
      I’ve used the “default” layout and the URL points to a local file, b/c Jenkins who executes the maven command runs on the same machine with the OBR.
    • -DprefixUrl – it’s the prefix used in the URL to the JAR bundle. Without this prefix the URL would look like “file:/com/x/y/myBundle.jar” and people won’t the able to download the actual bundle.
      I’ve then pointed my prefix to the Nexus Maven repository. During the maven release the bundle is deployed in that Nexus repository anyway, so I’v added it as a prefix for my bundle. With the prefix the URL looks like “http://nexus.mydomain.com/nexus/content/repositories/releases/com/x/y/myBundle.jar”.
  3. After a maven release, check if the OBR contains the update. Open the URL
    http://obr.mydomain.com/repository.xml

    again and the information should be there. Here is a sample repository.xml:

     
    <repository name="MediaCenter Bundle Repository" lastmodified="20120627090431.258">
        <resource id="org.mediacenter.authentication/1.18.0" symbolicname="org.mediacenter.authentication" presentationname="Media Center Authentication" uri="http://nexus.crestin.tv/nexus/content/repositories/releases/org/mediacenter/authentication/1.18/authentication-1.18.jar" version="1.18.0">
            <description>This bundle is a fragment attached to the Sling FormAuth bundle and provides        a simple customized login form.           </description>
            <size>6362</size>
            <category id="mediacenter"/>
            <capability name="bundle">
                <p n="symbolicname" v="org.mediacenter.authentication"/>
                <p n="presentationname" v="Media Center Authentication"/>
                <p n="version" t="version" v="1.18.0"/>
                <p n="manifestversion" v="2"/>
            </capability>
            <capability name="fragment">
                <p n="host" v="org.apache.sling.auth.selector"/>
                <p n="version" t="version" v="0.0.0"/>
            </capability>
            <require name="bundle" filter="(&amp;(symbolicname=org.apache.sling.auth.selector))" extend="true" multiple="false" optional="false">Required Host org.apache.sling.auth.selector</require>
        </resource>
    </repository>
  4. Go into the Felix Web Console, into the OSGI repository and add
    http://obr.mydomain.com/repository.xml

    as a new repository.

    Apache Felix OSGI Repository

Where to go from here:

  1. Apache Felix Maven Bundle Plugin
  2. Maven Release Plugin
  3. Using the Apache Felix Web Management Console

No Comments

No comments yet.

Sorry, the comment form is closed at this time.

Comments RSS Feed