I have an SBT project with 2 subprojects and I want to have test compiler settings different from the normal compiler settings, for all the subprojects. I.e. I want to enforce -Xfatal-warnings
for the main code but not for tests.
I'm looking for a solution that doesn't involve setting each subproject individuall but all at once.
I'm working with SBT 1.3.9 and Scala 2.13.3
This is a sample of what I have in SBT:
lazy val root: Project = project
.in(file("."))
.aggregate(projectA, projectB)
lazy val projectA: Project = project
.in(file("projectA"))
.settings(
name := "projectA",
)
lazy val projectB: Project = project
.in(file("projectA"))
.settings(
name := "projectA",
)
I tried plenty of options but I can't set test options different to compile options. As a quick summary, I tried to play around with scoping:
scalacOptions := Seq(XXX)
+Test/scalacOptions := Seq(YYY)
Compile/scalacOptions := Seq(XXX)
+Test/scalacOptions := Seq(YYY)
ThisBuild/scalacOptions := Seq(XXX)
+ThisBuild/Test/scalacOptions := Seq(YYY)
ThisBuild/Compile/scalacOptions := Seq(XXX)
+ThisBuild/Test/scalacOptions := Seq(YYY)
- Also tried to scope under
test
and played around with various combinations of the above.
This question is the closest to what I need but it doesn't work, probably beucase it's not meant for multiproject files.
UPDATE:
I've just discovered that if I scope the setting to a specific project then I have the behaviour I want:
projectA / Compile / scalacOptions := Seq(XXX)
projectA / Test / scalacOptions := Seq(YYY)
projectB / Compile / scalacOptions := Seq(XXX)
projectB / Test / scalacOptions := Seq(YYY)
but if I use ThisBuild
it doesn't work
ThisBuild / Compile / scalacOptions := Seq(XXX)
ThisBuild / Test / scalacOptions := Seq(XXX)
Do I have a wrong understanding of something or is this a bug?