mavenosgimaven-bundle-plugin

<Export-Package> for all resources using maven-bundle-plugin


As a temporary measure to be able to transition quickly to OSGi I need to create a single jar with all my libraries in it. What i did was put all the jar libraries in src/main/resources so they end up in the root of the created jar. The problem i am having is telling the maven-bundle-plugin to export ALL the packages in the jars. So basically, i want to expose all my libraries to other OSGi bundles

This is the first thing I tried in my POM

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Export-Package>*</Export-Package>
                    <Bundle-Name>${project.artifactId}</Bundle-Name>
                    <Bundle-Version>${project.version}</Bundle-Version>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>`

I tried to export everything there was. But it seems that the only thing that gets exported like this are the two osgi dependencies, not the jars in the resources

I have over a hundred libraries so i am trying to find an automated way to populate the <Export-Package> directive instead of adding each librarie's package by hand. Somehow eclipse does it in the plugin development environment, but i need to do this using maven. Is this possible with the bundle plugin at all? Extra points if the jars get added to the <Bundle-ClassPath>


Solution

  • I think this is not possible. The jars need to be individually in the maven repo to be able to create a "library project" by adding them as dependencies in the library project; otherwise the jars won't be in the classpath. A good reference for doing this is this page