我将Sbt Cross Building Plugin与sbt 0.13.1
一起使用。它工作正常,但我必须为所有定义的CrossBuilding.crossSbtVersions
指定较低的公共依赖版本。
如何定义libraryDependencies
,以便每个sbtVersion in sbtPlugin
使用最新的依赖版本?
答案 0 :(得分:4)
CrossBuilding.crossSbtVersions := Seq("0.12", "0.13")
中build.sbt
的以下解决方案效果很好:
libraryDependencies <++= (sbtVersion in sbtPlugin) { version =>
val V013 = """0\.13(?:\..*|)""".r
val (scalaz, scalatest) = version match {
case V013() => ("7.1.0-M4", "2.0.1-SNAP3")
case _ => ("7.0.5", "2.0.M6-SNAP3")
}
Seq(
"org.scalaz" %% "scalaz-concurrent" % scalaz % "embedded",
"org.scalatest" %% "scalatest" % scalatest % "test")
}
受SBT cross building - choosing a different library version for different scala version的启发。
答案 1 :(得分:3)
这是你想要的吗?
libraryDependencies <++= (sbtVersion in sbtPlugin) { version =>
val (scalaz, scalatest) = version match
case v if v startsWith "0.12" => ("7.0.5", "2.0.M6-SNAP3")
case v if v startsWith "0.13" => ("7.1.0-M4", "2.0.1-SNAP3")
}
Seq(
"org.scalaz" %% "scalaz-concurrent" % scalaz % "embedded",
"org.scalatest" %% "scalatest" % scalatest % "test")
}
它会错误地选择“0.121”之类的东西。你可以有一个正则表达式匹配器:
val V012 = """0\.12(?:\..*|)""".r
val V013 = """0\.13(?:\..*|)""".r
然后使用case V012() => ...
等