Recommended way to force a specific version of SBT dependency

我们两清 提交于 2019-11-30 04:44:43
Giovanni Caporaletti

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"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!