Reputation: 1868
I am upgrading from Scala 2.13 -> 2.13.
After many changes my project compiles from IntelliJ, but sbt fails on launch (before any tasks are launched) with compilation errors due to one of my upgrade changes (Stream -> LazyList).
My build.sbt file references Scala 2.13.12 however it appears that when launching sbt some of the plugin source files are being compiled against Scala 2.12.
Could anyone advise how to control the version of Scala that these plugin source files are compiled with?
Upvotes: 0
Views: 449
Reputation: 48410
The key is to understand the difference between sbt proper build and sbt meta build projects. Conceptually they can be viewed as two different Scala projects with their own versions of Scala which might differ. For example, consider the following experiement:
Create a project from template:
➜ stackoverflow sbt new scala/scala-seed.g8
[info] welcome to sbt 1.4.7 (AdoptOpenJDK Java 1.8.0_275)
[info] loading settings for project global-plugins from idea.sbt,plugins.sbt ...
[info] loading global plugins from /Users/mario_galic/.sbt/1.0/plugins
[info] set current project to stackoverflow (in build file:/Users/mario_galic/code/stackoverflow/)
[info] set current project to stackoverflow (in build file:/Users/mario_galic/code/stackoverflow/)
A minimal Scala project.
name [Scala Seed Project]: proper-build-vs-meta-build-scala-version
Template applied in /Users/mario_galic/code/stackoverflow/./proper-build-vs-meta-build-scala-version
Now create a build.sbt
file for the meta-build
➜ stackoverflow cd proper-build-vs-meta-build-scala-version
➜ proper-build-vs-meta-build-scala-version echo 'name := "meta-build-project"' > project/build.sbt
Now check the name and Scala version of the proper build
➜ proper-build-vs-meta-build-scala-version sbt
...
sbt:proper-build-vs-meta-build-scala-version> show name
[info] proper-build-vs-meta-build-scala-version
sbt:proper-build-vs-meta-build-scala-version> show scalaVersion
[info] 2.13.4
Now compare to the name and Scala version of the meta build
sbt:proper-build-vs-meta-build-scala-version> reload plugins
...
sbt:meta-build-project> show name
[info] meta-build-project
sbt:meta-build-project> show scalaVersion
[info] 2.12.12
Notice how meta-build is a separate project with its own scala version. The purpose of this project is to build your proper project. We say sbt is recursive.
Therefore migrating the proper project to Scala 2.13, does not affect the Scala version of the sbt plugins which are part of the meta-build.
Upvotes: 2