P2-maven-plugin - bundle conflicts with another existing package

I am starting to use the p2-maven-plugin to integrate a non-OSGi JAR into our project in a (hopefully) convenient way.

I have an artifact that I want OSGi-ify called com.thirdparty.artifact

. Im current using p2-maven-plugins default configuration and I am listing my artifact in the pom.xml

following way:

<artifact><id>com.thirdparty:artifact:1.2.3</id></artifact>

      

This artifact has a transitive dependency called com.thirdparty:library:2.5

, which exports a package com.thirdparty.library

, which is in turn imported com.thirdparty:artifact

. When I run mvn p2:site

I get a P2 site containing com.thirdparty:artifact:1.2.3

and com.thirdparty:library:2.5

- everything so far.

Things are getting messy now. My existing target framework already contains an artifact called com.othervendor:library

(a different vendor, it's there and I can't change it) that also exports the same package com.thirdparty.library

(but a completely different version).

At runtime, the OSGi / Eclipse black mask (which probably never fully understands) tries to resolve com.thirdparty:artifact

s dependencies on the package com.thirdparty.library

with com.othervendor:library

and not provided by me com.thirdparty:library:2.5

- and I'm clearly in trouble. Heres visualizes my situation:

StaightFromDependencyHell

Being absolutely not an OSGi booster, my first idea was to check MANIFEST.MF

in com.thirdparty:artifact

. Among others, this shows the following:

Import-Package: com.thirdparty.library

      

So this obviously just says to com.thirdparty:artifact

import this package from package some , and OSGi / Eclipse thinks "good, com.othervendor:library

more adequate than com.thirdparty:library

".

There seem to be two methods for narrowing the dependencies for actual use. However: I'm not sure (a) how to integrate them into the workflow p2-maven-plugin

, and (b) I don't understand why it p2-maven-plugin

doesn't require automatic installation of a specific version of the package in the directive Import-Package

(this information after everything is already stated in the source pom.xml

).

I may not see a forest for trees here. So any general advice other than my questions above is highly appreciated!


[edit] Heres my pom.xml

(library specific, Im Im to OSGi-ify - Selenium):

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>com.example.p2dependencies</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <build>
    <plugins>
      <plugin>
        <groupId>org.reficio</groupId>
        <artifactId>p2-maven-plugin</artifactId>
        <version>1.2.0</version>
        <executions>
          <execution>
            <id>default-cli</id>
            <configuration>
              <artifacts>
                <artifact><id>org.seleniumhq.selenium:selenium-java:3.4.0</id></artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

      


[edit2] The problem seems to be solved, it seems the problem was an extra package that was only exported com.othervendor:library

.

+3


source to share





All Articles