I'm migrating an old project to Scala 3. The build.sbt is as follows:
import Dependencies._
inThisBuild(
Seq(
scalaVersion := "2.12.7",
scalacOptions ++= Seq(
"-unchecked",
// more
)
)
++ inConfig(Test)(Seq(
testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-o", "-e"),
// more
))
)
lazy val root = (project in file("."))
.aggregate(
`test-util`
)
lazy val `test-util` = project
Now, I want to separate stuff inside inThisBuild for legibility.
import Dependencies._
ThisBuild / scalaVersion := "3.0.1"
ThisBuild / scalacOptions ++= Seq(
"-unchecked",
// more
)
lazy val testSettings = inConfig(Test)(
Seq(
testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-o", "-e"),
// more
))
lazy val root = (project in file("."))
.aggregate(
`test-util`
)
.settings(testSettings)
lazy val `test-util` = project
As you can see, I'm having to apply the testSettings for each project. Ideally, I'd like to do something like ThisBuild / Test := testSettings but that is not valid syntax.
Is there a way to apply the testSettings to all projects without having to explicitly set .settings(testSettings)?
Edit:
I understand I can write each line of testSettings with ThisBuild / Test prefix, but I’d rather not repeat the same prefix. I’m looking for something like what I’ve done with scalacOptions.