How to change Scala version for sbt project?

前端 未结 1 1353
离开以前
离开以前 2020-12-09 14:59

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.

1条回答
  •  甜味超标
    2020-12-09 15:12

    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 ++.
    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.

    0 讨论(0)
提交回复
热议问题