free_easy
free_easy

Reputation: 5129

maven-bundle-plugin problem (OSGI)

I have a project with produces an OSGI bundle using the maven-bundle-plugin. The configuration looks like this:

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.1.0</version>
    <extensions>true</extensions>
    <inherited>true</inherited>
    <configuration>
        <instructions>
            <Export-Package>${bubble.osgi.exports}</Export-Package>
            <Import-Package>${bubble.osgi.imports}</Import-Package>
            <Embed-Dependency>${bubble.osgi.embed.dependencies}</Embed-Dependency>

            <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
        </instructions>
        <versions>
            <bubble.osgi.version.clean>${project.version}</bubble.osgi.version.clean>
        </versions>
    </configuration>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>cleanVersions</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The outcome of the project is a single jar file with all the osgi stuff, embedded dependencies etc. included. I rather would like to have 2 jars as outcome, one with the osgi stuff included and one without, as the embedded dependencies cause problems when using it just as a plain jar.

Is there any other way than using the maven assembly plugin for this?

Upvotes: 1

Views: 1375

Answers (2)

FrVaBe
FrVaBe

Reputation: 49341

I would recommend to use 2 different pom.xml files (in the project) which will produces 2 different artifacts.

The default pom.xml should generate the plain library like foo:bar:1.0.0

Another pom-osgi.xml should generate the OSGi library like foor:bar-osgi:1.0.0

To build the library with another pom use

mvn -f pom-osgi.xml install

Upvotes: 2

darwin
darwin

Reputation: 364

You can move maven-bundle-plugin configuration into separate profile and use something like

mvn package -Posgi or default. But there will only one artifact produced per build.

Upvotes: 2

Related Questions