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
~/foo$
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
│ ├── build.properties
│ └── 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("."))
.settings(
name := "foo",
libraryDependencies += scalaTest % Test
)
// See https://www.scala-sbt.org/1.x/docs/Using-Sonatype.html for instructions on how to publish to Sonatype.
~/foo$ cat project/build.properties
sbt.version=1.5.5
~/foo$ cat project/Dependencies.scala
import sbt._
object Dependencies {
lazy val scalaTest = "org.scalatest" %% "scalatest" % "3.2.8"
}