How to resolve transient dependency version conflicts (scala / sbt)

I have a project with several utility classes. Call him Utils. I have proj1one that depends on Utils. And yet proj2, which depends on proj1and Utils.

The problem is that both proj1and proj2are dependent on other versions Utilsthat will lead to problems.

What is the best solution?

This situation arises in Scala / SBT projects, but I think other languages ​​have the same problems.

Edit:

To be clear, proj2this is a project that will be launched that uses some code from proj1and Utils.

+4
source share
2 answers

This is a classic Jar Hell , and this is a problem for any JVM-based project, not just scala with sbt.

There are 4 common solutions.

  • Get rid of the conflict by changing the code, combine your dependency on several versions into one dependency.

  • Shading (as mentioned by @Sean Viera above)

  • Multiple ClassLoader component architectures such as OSGI (as @tuxdna mentioned)

  • Running in separate JVMs such as microservice architecture (also mentioned by @tuxdna)

+2
source

You have three different projects:

  • Utils
  • proj1 <- depends on Utils v1
  • proj2 <- depends on Utils v2

The only way you can be 100%sure that conflicts between proj1 and proj2 should not be isolated.

proj1 proj2 Utils , .

, :

  • JVM, Utils
  • JVM,
+1

Source: https://habr.com/ru/post/1617128/


All Articles