Scala version used to compile files under project folder

Hello all,

A question about sbt: where is the Scala version used to compile files under “project” folder defined?

I mean, for example, if I have a project using Scala 2.13 like one created from scala/scala-seed:

~$ sbt new scala/scala-seed.g8
[info] welcome to sbt 1.5.5 (Ubuntu Java 11.0.11)
[info] loading global plugins from /home/fcv/.sbt/1.0/plugins
[info] set current project to new (in build file:/tmp/sbt_2a7b80ce/new/)

A minimal Scala project. 

name [Scala Seed Project]: foo

Template applied in /home/fcv/./foo

~$ cd foo/
~/foo$ sbt compile
[info] welcome to sbt 1.5.5 (Ubuntu Java 11.0.11)
[info] loading global plugins from /home/fcv/.sbt/1.0/plugins
[info] loading project definition from /home/fcv/foo/project
[info] compiling 1 Scala source to /home/fcv/foo/project/target/scala-2.12/sbt-1.0/classes ...
[info] loading settings for project root from build.sbt ...
[info] set current project to foo (in build file:/home/fcv/foo/)
[info] Executing in batch mode. For better performance use sbt's shell
[info] compiling 1 Scala source to /home/fcv/foo/target/scala-2.13/classes ...
[success] Total time: 2 s, completed Sep 15, 2021, 4:27:47 PM

From the output above I take (pls, correct me if I’m wrong) that files under “project” folder were compiled using Scala 2.12 while files under “src” were compiled using 2.13.

Where is 2.12 defined?

Can I change it in my project so files under “project” folder are compiled using the same version as the one defined in build.sbt ?

Thanks in advance.

Ps: project’s file structure:

~/foo$ tree
├── build.sbt
├── project
│   ├──
│   └── Dependencies.scala
└── src
    ├── main
    │   └── scala
    │       └── example
    │           └── Hello.scala
    └── test
        └── scala
            └── example
                └── HelloSpec.scala

8 directories, 5 files
~/foo$ cat build.sbt 
import Dependencies._

ThisBuild / scalaVersion     := "2.13.6"
ThisBuild / version          := "0.1.0-SNAPSHOT"
ThisBuild / organization     := "com.example"
ThisBuild / organizationName := "example"

lazy val root = (project in file("."))
    name := "foo",
    libraryDependencies += scalaTest % Test

// See for instructions on how to publish to Sonatype.
~/foo$ cat project/ 
~/foo$ cat project/Dependencies.scala 
import sbt._

object Dependencies {
  lazy val scalaTest = "org.scalatest" %% "scalatest" % "3.2.8"

No. That’s because sbt >= 1.x still uses Scala 2.12 exclusively and that’s what is used for the project files and plugins.

Well, you can change the version, but that probably will just cause you problems.

Why do you even care?

Why do you even care?

It’s not a big deal, at this point is more out of curiosity.

I use hseeberger/scala-sbt docker image in my CI pipelines and I noticed that for every build it takes some time compiling compiler-bridge_2.12 module:

[info] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.14. Compiling...
[info]   Compilation completed in 28.834s.
[info] done compiling

So, at first I was wondering why it would even need a “‘compiler-bridge_2.12’ for Scala 2.12.14” when my project is using Scala 2.13… then I realized it was using 2.12 to compile files under project folder, so I wondered why.

That’s why I asked … out of curiosity and, in case it was something easy changed, I would change it to avoid this compilation step.