尤其考虑以下一些build.sbt和没有源代码的内容:
lazy val y = (project in file("y"))
.settings(
scalaVersion := "2.11.8",
)
.dependsOn(x)
lazy val x = (project in file("x"))
.settings(
crossScalaVersions := Seq("2.11.8", "2.12.6")
)
在这里, sbt y/compile, 失败了
sbt.librarymanagement.ResolveException: unresolved dependency: x#x_2.11;0.1.0-SNAPSHOT: not found
这是通过sbt "show y/fullResolvers"参考解释
Raw(ProjectResolver(inter-project, mapped: x#x_2.12;0.1.0-SNAPSHOT))
为什么它指的是_2.12?我想既然sbt "show y/allDependencies"列表
x:x:0.1.0-SNAPSHOT
作为缺少scalaVersion和的依赖项, _2.12sbt 不理解(与外部库依赖项不同)要查找的 scala 版本。_2.12似乎源自默认为某些 2.12.x 的 or 值,更改范围ThisBuild之一Global可以解决上述简化示例的问题,但如果我们添加scalaVersionscalaVersion
lazy val z = (project in file("z"))
.settings(
scalaVersion := "2.12.6",
)
.dependsOn(x)
那么我们scalaVersion在Global / ThisBuild范围内选择的任何价值,要么无法建立,要么y将z无法建立。
我知道sbt "+ y/compile"但为什么不sbt y/compile正确默认为scalaVersion依赖项目和依赖项之间的匹配?还是可以scalaVersion在解决依赖关系时选择正确的?
sbt "show sbtVersion"给了我1.2.1,但我在不同版本中看到了同样的问题,以前没有在线解释帮助我理解/规避问题。