如何更改 sbt 项目的 Scala 版本?

发布于 2024-09-03 02:19:37 字数 72 浏览 3 评论 0原文

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

我想让SBT检查系统的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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回忆凄美了谁 2024-09-10 02:19:37

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
reload
set build.scala.versions 2.8.0.RC2
reload

每次触发不同 Scala 版本的编译。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文