How to use multiple versions of a library in Scala?

I am using a library, say A in Scala, which depends on the x.11 version of another library, say Z.

Now I also use a library that says B, which depends on version x.31 of Z.

This leads to a compilation error, because we will have two versions of the Z library, how can I use both the A and B libraries in Scala sbt? Is there any way to specify it.

+4
source share
2 answers

In sbt, conflicts between libraries are configured using the conflict manager. The latest revision is selected by default, but this can also be overridden in the .sbt file:

conflictManager := ConflictManager.strict

sbt 0.13.6 , , . sbt :

dependencyOverrides += "org.raman" % "Z" % "x.11"

Z x.11, .

0

, Sparko. .

uber-jar, sbt-assembly, . . , , , .

sbt-assembly , - , , . , Spark, Uber Jars Shading sbt-assembly, . :

, , Spark . build.sbt :

assemblyShadeRules : = Seq (
ShadeRule.rename( "com.typesafe.config. **" → "my_conf. @1" )     .inLibrary( "com.typesafe" % "config" % "1.3.0" )     .inProject)

, com.typesafe.config my_conf.

- build.sbt:

assemblyShadeRules in assembly := Seq(
      ShadeRule.rename("com.somecompany.**" -> "my_conf.@1")
      .inLibrary("com.somecompany" % "libraryZ" % "0.11")
      .inProject
    )
0

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


All Articles