sbt-crossproject default project has different scalaVersion than I set. Why?

42 views Asked by At

I'm writing a cross-compiled library between JSPlatform and JVMPlatform using sbt-scalajs-crossproject. I've explicitly set scalaVersion in common settings and yet:

sbt:oatlibxp> show scalaVersion
[info] oatlibxpJS / scalaVersion
[info]  2.13.11
[info] oatlibxpJVM / scalaVersion
[info]  2.13.11
[info] scalaVersion
[info]  2.12.18                 <<---- WHY?

Why is the last one (the default project) different from the others? For what it's worth, the values for version, scalacOptions, etc are also different.

Here is my build.sbt (I've removed some settings like libraryDependencies that I think are not relevant):

val sharedSettings = Seq(
  version      := "3.0.0-SNAPSHOT",
  name         := "oatLibXP",
  scalaVersion := "2.13.11",
  scalacOptions ++= Seq("-feature", "-deprecation", "-unchecked"),
)

lazy val oatlibxp = crossProject(JSPlatform, JVMPlatform)
  .crossType(CrossType.Full)
  .in(file("."))
  .settings(sharedSettings)

And my directory structure:

% tree -d -L 3 -I target
.
├── js
│   └── src
│       └── main
├── jvm
│   └── src
│       ├── main
│       └── test
├── project
│   └── project
└── shared
    └── src
        ├── main
        └── test

14 directories

Version numbers:

  • sbt: 1.9.0
  • sbt-scalajs-crossproject: 1.2.0
  • sbt-scalajs: 1.13.0
1

There are 1 answers

2
sjrd On BEST ANSWER

That's the value of the setting for the root project, which is only an aggregate. So it doesn't really matter. If, for your peace of mind, you still want it to be the same, I recommend you put this at the top level of your build:

ThisBuild / scalaVersion := "2.13.11"