如何更改 sbt 项目的 Scala 版本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2888031/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change Scala version for sbt project?
提问by ?ukasz Lew
How can I change Scala version in a sbt project?
如何在 sbt 项目中更改 Scala 版本?
I would like SBT to check whether the system's Scala version is correct and if it is not the case then download it.
我希望 SBT 检查系统的 Scala 版本是否正确,如果不是,则下载它。
回答by VonC
xsbt (0.10+, including the latest 0.13.7)
xsbt(0.10+,包括最新的 0.13.7)
Change scalaVersionin build.sbtto whatever Scala version your project should be using - see .sbt build definition.
更改scalaVersion在build.sbt您的项目应该使用什么版本斯卡拉-见名.bst构建定义。
scalaVersion := "2.10.1"
sbt:
sbt:
As mentioned in RunningSBT, you can:
如RunningSBT 中所述,您可以:
You can temporarily switch to another version of Scala using
++<version>.
This version does not have to be listed in yourbuild.scala.versionsproperty, but it does have to be in a repository or be a local Scalaversion you have defined.
您可以使用
++<version>.
此版本不必列在您的build.scala.versions属性中,但它必须位于存储库中或您定义的本地 Scala版本。
But the CrossBuild pageis more suited for what you want, as it shows in action how to change the build.scala.versionsproperty.
但CrossBuild 页面更适合您的需求,因为它显示了如何更改build.scala.versions属性的实际操作。
So you should be able to
所以你应该能够
set build.scala.versions 2.7.7
reload
set build.scala.versions 2.8.0.RC2
reload
and each time trigger a compilation with a different Scala version.
并且每次都使用不同的 Scala 版本触发编译。

