SBT 交叉构建 - 为不同的 Scala 版本选择不同的库版本 [英] SBT cross building - choosing a different library version for different scala version
本文介绍了SBT 交叉构建 - 为不同的 Scala 版本选择不同的库版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将 SBT 配置为在交叉构建时使用完全不同的库版本,具体取决于构建项目所使用的 Scala 版本?
例如:
- 使用 Scala 构建时
2.9.2
我想使用"org.scalatest" % "scalatest_2.9.2" % "2.0.M5" % "test"
- 使用 scala
2.10.0
构建时,我想使用"org.scalatest" % "scalatest_2.10.0-RC5" % "2.0.M5-B1" % "test"
解决方案
这样的事情应该可行:
libraryDependencies <+= scalaVersion(scalatestDependency(_))def scalatestDependency(scalaVersion: String) = scalaVersion match {情况2.9.2"=>"org.scalatest" % "scalatest_2.9.2" % "2.0.M5" % "test"情况2.10.0"=>org.scalatest"%scalatest_2.10.0-RC5"%2.0.M5-B1"%测试"}
我假设您实际上是说库版本应该是相反的?:-)
您可以在 ScalaMock 2 构建中看到此主题的变体.>
Is it possible to configure SBT to use a completely different library version when cross building, depending on the scala version the project is being built with?
For example:
- When building with Scala
2.9.2
I want to use"org.scalatest" % "scalatest_2.9.2" % "2.0.M5" % "test"
- When building with scala
2.10.0
I want to use"org.scalatest" % "scalatest_2.10.0-RC5" % "2.0.M5-B1" % "test"
解决方案
Something like this should work:
libraryDependencies <+= scalaVersion(scalatestDependency(_))
def scalatestDependency(scalaVersion: String) = scalaVersion match {
case "2.9.2" => "org.scalatest" % "scalatest_2.9.2" % "2.0.M5" % "test"
case "2.10.0" => "org.scalatest" % "scalatest_2.10.0-RC5" % "2.0.M5-B1" % "test"
}
I assumed that you actually meant that the library versions should be the other way around? :-)
You can see variations on this theme in the ScalaMock 2 build.
这篇关于SBT 交叉构建 - 为不同的 Scala 版本选择不同的库版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文