How to force a specific version of dependency?

前端 未结 1 1777
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 03:07

A dependency bar depends on foo 1.2.3, but that version of foo has a bug and I need to use version 1.2.2.

I can do that with

相关标签:
1条回答
  • 2020-12-03 03:38

    you can use dependencyOverrides:

    dependencyOverrides += "foo" %% "foo" % "1.2.2"
    

    You're not avoiding "logical inconsistencies" anyway. If you force a version, you have to manually take care of compatibility with other libraries, there's no way out of that.

    From the documentation:

    Overriding a version

    For binary compatible conflicts, sbt provides dependency overrides. They are configured with the dependencyOverrides setting, which is a set of ModuleIDs. For example, the following dependency definitions conflict because spark uses log4j 1.2.16 and scalaxb uses log4j 1.2.17:

    libraryDependencies ++= Seq(
      "org.spark-project" %% "spark-core" % "0.5.1",    
      "org.scalaxb" %% "scalaxb" % "1.0.0" ) 
    

    The default conflict manager chooses the latest revision of log4j, 1.2.17:

    show update 
    [info] compile: 
    [info]    log4j:log4j:1.2.17: ... ... 
    [info]    (EVICTED) log4j:log4j:1.2.16 ... 
    

    To change the version selected, add an override:

    dependencyOverrides += "log4j" % "log4j" % "1.2.16"
    
    0 讨论(0)
提交回复
热议问题