19

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"

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  

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?

Mark
  • 5,286
  • 5
  • 42
  • 73

2 Answers2

26

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:

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"
Mark
  • 5,286
  • 5
  • 42
  • 73
6

SBT has a default Scala version. You need to add the scalaVersion setting to all subprojects if you wish to change it. The most common way of doing that is having a "common settings" value that is added to all projects at the root level, through project/Build.scala.

Daniel C. Sobral
  • 295,120
  • 86
  • 501
  • 681