sbt 如何选择使用哪个 Scala 版本? [英] How does sbt choose which Scala version to use?

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

问题描述

我的 sbt 版本中有多个项目.我正在尝试从 2.9.1 升级到 Scala 2.10,所以在我的 build.sbt 文件中我放了

I have multiple projects in my sbt build. I'm trying to upgrade to Scala 2.10 from 2.9.1, so in my build.sbt file I put

scalaVersion := "2.10.0"

这似乎有效,因为在我在 sbt 的顶级项目中我得到:

This seemed to work, because in my top-level project in sbt I get:

> scala-version
[info] 2.10.0  

但是,当我切换到其他项目之一时:

However, when I switch to one of the other projects:

> project web-client
[info] Set current project to web-client (in build file:/C:/Users/...
[web-client] $ scala-version
[info] 2.9.1  

您看到版本现在已更改回 2.9.1!如何强制在我的所有项目中使用相同的 Scala 版本?

You see the version has now changed back to 2.9.1! How do I force the same Scala version to be used across all my projects?

推荐答案

我发现将 scalaVersion 范围限定为 ThisBuild 将为所有子项目设置它.详细信息在这里:http://www.scala-sbt.org/release/docs/Getting-Started/Multi-Project.html 位于底部,但内容如下:

I found out scoping the scalaVersion to ThisBuild will set it for all sub-projects. Details are here: http://www.scala-sbt.org/release/docs/Getting-Started/Multi-Project.html at the bottom, but here is what it says:

如果只设置一次,在主 build.sbt 文件中写入以下行就足够了:

To set it only once, it is enough to write, in the main build.sbt file, the following line:

scalaVersion in ThisBuild := "2.10.0"

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

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