4

I am running into a problem where I have the following 2 dependencies:

org.apache.felix » org.apache.felix.utils » 1.6.0

and

com.github.rotty3000 » phidias » 0.3.2

they both have transitive dependency on org.osgi.core, felix depends on version 4.1.0 and phidias depends on version 5.0.0

we need version 5.0.0 for our code to correctly compile

if I put my dependencies as:

<dependencies>
    <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.utils</artifactId>
        <version>1.6.0</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.github.rotty3000</groupId>
        <artifactId>phidias</artifactId>
        <version>0.3.2</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

maven automatically gets version 4.1.0 causing compile error. If I put phidias on top of felix it would get version 5.0.0 and compile fine.

we want to order the dependencies in alphabetical order so felix will go on top, is there anyway to force osgi.core to resolve the 5.0.0 version?

Thanks!

Fabien
  • 859
  • 6
  • 15
tom
  • 445
  • 4
  • 20

1 Answers1

5

<exclude> it from both of those dependency

add org.osgi.core's required dependency at version 5.0.0 in your pom.xml as an explicit dependency with your required version

make sure the two libraries you are consuming are runtime compatible with 5.0.0

jmj
  • 237,923
  • 42
  • 401
  • 438
  • 1
    I agree with this solution because if you cannot compile your application with the version 4.1.0 which is provided by transitivity then it means that you should declare the dependency in your pom.xml with the version required for your compilation to be successful. – Fabien May 01 '15 at 07:50
  • this is a complicated project where our base code is using ivy and I am making an automated port to maven by parsing the ivy files, manually making the exception is doable but definitely not the preferred solution. I will wait a day to see if anyone have another way to force the 5.0.0, if no other options this would be the solution for it – tom May 01 '15 at 15:52
  • @Fabien the 5.0.0 version is also a transitive dependency for the other direct dependency, i guess if I exclude it from felix it should also work – tom May 01 '15 at 15:54
  • @tom I exactly know what you mean by that, but if you want to automate it, you would have to consider this fact – jmj May 01 '15 at 16:18