Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Scala version for sbt project?

Tags:

scala

sbt

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.

like image 732
Łukasz Lew Avatar asked May 22 '10 12:05

Łukasz Lew


People also ask

Which Scala version does sbt use?

sbt uses that same version of Scala to compile the build definitions that you write for your project because they use sbt APIs. This version of Scala is fixed for a specific sbt release and cannot be changed. For sbt 1.7. 1, this version is Scala 2.12.

Does sbt install Scala?

sbt will download Scala for you. If you install sbt-extras (basically just a script) you don't even need to download sbt : it will automatically download the sbt launcher you need. Very handy since you just need to specify sbt. version in your build.

How do I change the Scala version in Intellij?

 In most cases your project JDK is not compatible with Scala or sbt version, try to change the Scala Compile Server SDK. Press Ctrl+Alt+S to open Settings/Preferences dialog. From the options on the left, select Build, Execution, Deployment | Compiler | Scala | Scala Compiler Server.


1 Answers

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.

like image 194
VonC Avatar answered Oct 02 '22 20:10

VonC