Skip to content

Commit 32db1ae

Browse files
committed
SdPlugin / scalacOptions: only add -Xfatal-warnings for scala 2.12 & 2.13 in Compile
TODO enable -Xfatal-warnings for scala3 when this is RELEASED: scala/scala3#12857
1 parent e3f9970 commit 32db1ae

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

sd/src/main/scala/com/sandinh/sbtsd/SdPlugin.scala

+12-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ object SdPlugin extends AutoPlugin {
2828
)
2929

3030
override def projectSettings: Seq[Setting[?]] = Seq(
31-
scalacOptions ++= sdScalacOptions(scalaVersion.value)
31+
scalacOptions ++= sdScalacOptions(scalaVersion.value),
32+
Compile / scalacOptions ++= (scalaBinaryVersion.value match {
33+
// scala 2.11 don't support -Wconf.
34+
// So, for convenience, we don't add -Xfatal-warnings
35+
case "2.11" => Nil
36+
// TODO enable -Xfatal-warnings when this is RELEASED in scala3:
37+
// https://github.com/lampepfl/dotty/pull/12857
38+
case "3" => Nil
39+
case _ => Seq("-Xfatal-warnings")
40+
}),
3241
)
3342

3443
val skipPublish: Seq[Setting[?]] = Seq(
@@ -39,14 +48,15 @@ object SdPlugin extends AutoPlugin {
3948
/** @param scalaVersion scala version. Ex 2.11.12, 3.1.0-RC2,..
4049
* @return default scalacOptions for all sandinh's projects
4150
* @see [[https://docs.scala-lang.org/scala3/guides/migration/options-lookup.html Compiler Options Lookup Table]]
51+
* @see [[https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html Configuring and suppressing warnings]]
52+
* @see [[https://github.com/lampepfl/dotty/pull/12857 Support -Wconf and @nowarn in scala3]]
4253
*/
4354
def sdScalacOptions(scalaVersion: String): Seq[String] = {
4455
val Some((major, minor)) = CrossVersion.scalaApiVersion(scalaVersion)
4556
val opts = ListBuffer( // format: off
4657
"-encoding", "UTF-8", // format: on
4758
"-deprecation",
4859
"-feature",
49-
"-Xfatal-warnings",
5060
)
5161
if ((major, minor) == (2, 11)) opts += "-Ybackend:GenBCode"
5262
if (major == 2 && minor < 13) opts += "-target:jvm-1.8"

0 commit comments

Comments
 (0)