如何更改 sbt 项目的 Scala 版本? [英] How to change Scala version for sbt project?

查看:67
本文介绍了如何更改 sbt 项目的 Scala 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 sbt 项目中更改 Scala 版本?

我希望 SBT 检查系统的 Scala 版本是否正确,如果不正确,请下载.

解决方案

xsbt(0.10+,包括最新的0.13.7)

build.sbt 中的 scalaVersion 更改为您的项目应该使用的任何 Scala 版本 - 请参阅 .sbt 构建定义.

scalaVersion := "2.10.1"

<小时>

sbt:

RunningSBT 所述,您可以:><块引用>

您可以使用 ++ 临时切换到另一个版本的 Scala.
此版本不必列在您的 build.scala.versions 属性中,但必须位于存储库中或 您定义的本地 Scala 版本.

但是CrossBuild 页面更适合您想要,因为它在行动中展示了如何更改 build.scala.versions 属性.

所以你应该能够

set build.scala.versions 2.7.7重新加载设置 build.scala.versions 2.8.0.RC2重新加载

并且每次都使用不同的 Scala 版本触发编译.

How can I change Scala version in a sbt project?

I would like SBT to check whether the system's Scala version is correct and if it is not the case then download it.

解决方案

xsbt (0.10+, including the latest 0.13.7)

Change scalaVersion in build.sbt to whatever Scala version your project should be using - see .sbt build definition.

scalaVersion := "2.10.1"


sbt:

As mentioned in RunningSBT, you can:

You can temporarily switch to another version of Scala using ++<version>.
This version does not have to be listed in your build.scala.versions property, but it does have to be in a repository or be a local Scala version you have defined.

But the CrossBuild page is more suited for what you want, as it shows in action how to change the build.scala.versions property.

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.

这篇关于如何更改 sbt 项目的 Scala 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆