[英]How to specify different libraryDependencies per sbtVersion in sbtPlugin with sbt-cross-building and sbt 0.13?
I use Sbt Cross Building Plugin with sbt 0.13.1
. 我使用Sbt Cross Building Plugin和sbt
0.13.1
。 It works fine, but I had to specify the lower common dependency versions for all the CrossBuilding.crossSbtVersions
defined. 它工作正常,但我必须为所定义的所有
CrossBuilding.crossSbtVersions
指定较低的常见依赖版本。
How can I define libraryDependencies
so it uses the most recent dependency version per sbtVersion in sbtPlugin
? 如何定义
libraryDependencies
以便它sbtVersion in sbtPlugin
使用每个sbtVersion in sbtPlugin
最新依赖版本?
The following solution for CrossBuilding.crossSbtVersions := Seq("0.12", "0.13")
in build.sbt
works well: 对下述溶液
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")
}
Inspired by SBT cross building - choosing a different library version for different scala version . 灵感来自SBT跨建筑 - 为不同的scala版本选择不同的库版本 。
Is this what you want? 这是你想要的吗?
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")
}
It will pick things like "0.121" incorrectly. 它会错误地选择“0.121”之类的东西。 You could have a regex matcher for that:
你可以有一个正则表达式匹配器:
val V012 = """0\.12(?:\..*|)""".r
val V013 = """0\.13(?:\..*|)""".r
And then use case V012() => ...
, etc. 然后使用
case V012() => ...
等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.