Neoasimov
Neoasimov

Reputation: 1111

Issues with Clojure inter-dependency with different major versions of the same library

Disclojure: I am not a Java developer and I have little knowledge in Maven.

I am facing a problem with Clojure/Lein. I am developing a project that uses two external libraries/projects that are un-related. Both of the uses the Sesame RDF library. One of them is Any23 which uses Sesame 2.x but the other uses the version 4.x. The problem is that Any23 won't work with Sesame 4.x and the other library won't work with Sesame 2.x.

This means that :exclusions one or the other in my project.clj file won't work.

Do any solution exists to fix such dependencies issues or am I stuck?

Upvotes: 2

Views: 381

Answers (1)

Daniel Compton
Daniel Compton

Reputation: 14559

There aren't any easy answers for this problem. Here are some options:

  • Upgrade Any23 to use Sesame 4.x
  • Use something like Maven Shade to rename one of the Sesame packages so that they can both be loaded on the same classpath. You may run into trouble if you try to use or share objects between the two libraries.
  • Use Clojure OSGI to isolate the packages. (This is probably the most difficult option, although also the most 'correct').

For more info, see Java, Classpath, Classloading => Multiple Versions of the same jar/project and Wikipedia's entry on JAR Hell.

Upvotes: 2

Related Questions