Search code examples
osgiapache-felix

Add jar to apache felix in Pom file?


How can I add a jar to my bundle in Apache Felix?

I am using maven, with maven-bundle-plugin to manage my bundles in OBR for me.

But I am not sure where to declare the dependency inside my POM on the jar, so that maven correctly compiles it into the final bundle.

This is how my plugin looks in pom:

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<configuration>
    <instructions>
        <Bundle-Category>sample</Bundle-Category>
        <Bundle-SymbolicName>${artifactId}
                 </Bundle-SymbolicName>
        <Export-Package>
            //blahblah
        </Export-Package>
    </instructions>

    <!-- OBR -->
    <remoteOBR>repo-rel</remoteOBR>
    <prefixUrl>file:///C:/Users/blah/Projects/Eclipse3.6-RCP-64/Felix/obr-repo/releases</prefixUrl>
    <ignoreLock>true</ignoreLock>
</configuration>


Solution

  • If you have a dependecy like this

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
    </dependency>
    

    you can embed it in your bundle with

    <instructions>
        <!-- embedded dependencies -->
        <Embed-Dependency>log4j;groupId=log4j;inline=false</Embed-Dependency>
    </instructions>
    

    You will find a detailed description in the "Embed Dependency" section of the Bundle Plugin for Maven site