@@ -10,10 +10,26 @@ startYear := Some(2023)
10
10
11
11
crossScalaVersions := Seq (" 2.13.16" , " 3.3.6" )
12
12
scalaVersion := crossScalaVersions.value.head
13
- scalacOptions := Seq (
14
- " -release:17" ,
15
- " -Xsource:3" ,
16
- " -deprecation" ,
13
+ scalacOptions := crossSettings(
14
+ scalaVersion = scalaVersion.value,
15
+ if2 = Seq (
16
+ " -Xsource:3" ,
17
+ ),
18
+ // Good compiler options for Scala 2.13 are coming from com.evolution:sbt-scalac-opts-plugin:0.0.9,
19
+ // but its support for Scala 3 is limited, especially what concerns linting options.
20
+ //
21
+ // If Scala 3 is made the primary target, good linting scalac options for it should be added first.
22
+ if3 = Seq (
23
+ " -Ykind-projector:underscores" ,
24
+
25
+ // disable new brace-less syntax:
26
+ // https://alexn.org/blog/2022/10/24/scala-3-optional-braces/
27
+ " -no-indent" ,
28
+
29
+ // improve error messages:
30
+ " -explain" ,
31
+ " -explain-types" ,
32
+ ),
17
33
)
18
34
autoAPIMappings := true
19
35
versionScheme := Some (" early-semver" )
@@ -27,6 +43,13 @@ libraryDependencies ++= Seq(
27
43
28
44
licenses := Seq ((" MIT" , url(" https://opensource.org/licenses/MIT" )))
29
45
46
+ def crossSettings [T ](scalaVersion : String , if3 : T , if2 : T ): T = {
47
+ scalaVersion match {
48
+ case version if version.startsWith(" 3" ) => if3
49
+ case _ => if2
50
+ }
51
+ }
52
+
30
53
addCommandAlias(" fmt" , " all scalafmtAll scalafmtSbt" )
31
54
addCommandAlias(" check" , " all versionPolicyCheck scalafmtCheckAll scalafmtSbtCheck" )
32
55
addCommandAlias(" build" , " all compile test" )
0 commit comments