-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler.sbt
124 lines (109 loc) · 2.51 KB
/
compiler.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
ThisBuild / scalaVersion := "2.12.19"
ThisBuild / crossScalaVersions := Seq(
"2.11.12",
scalaVersion.value,
"2.13.14",
"3.4.2"
)
crossVersion := CrossVersion.binary
ThisBuild / scalacOptions ++= Seq(
"-encoding",
"UTF-8",
"-unchecked",
"-deprecation",
"-feature",
"-Xfatal-warnings"
)
ThisBuild / scalacOptions ++= {
val v = scalaBinaryVersion.value
if (v == "2.13") {
Seq(
"-release",
"8",
"-Xlint",
"-g:vars"
)
} else if (v startsWith "2.") {
Seq(
"-target:jvm-1.8",
"-Xlint",
"-g:vars"
)
} else {
Seq("-release", "8")
}
}
ThisBuild / scalacOptions ++= {
val sv = scalaBinaryVersion.value
if (sv == "2.12") {
Seq(
"-Xmax-classfile-name",
"128",
"-Ywarn-numeric-widen",
"-Ywarn-dead-code",
"-Ywarn-value-discard",
"-Ywarn-infer-any",
"-Ywarn-unused",
"-Ywarn-unused-import",
"-Ywarn-macros:after"
)
} else if (sv == "2.11") {
Seq(
"-Xmax-classfile-name",
"128",
"-Yopt:_",
"-Ydead-code",
"-Yclosure-elim",
"-Yconst-opt"
)
} else if (sv == "2.13") {
Seq(
"-explaintypes",
"-Werror",
"-Wnumeric-widen",
"-Wdead-code",
"-Wvalue-discard",
"-Wextra-implicit",
"-Wmacros:after",
"-Wunused"
)
} else {
Seq(
"-Wunused:all",
"-language:implicitConversions",
"-Wconf:msg=.*is\\ not\\ declared\\ infix.*:s",
"-Wconf:msg=.*function.*\\ _.*no\\ longer\\ supported.*:s",
"-Wconf:msg=.*is\\ no\\ longer\\ supported\\ for\\ vararg\\ splices.*:s"
)
}
}
Compile / console / scalacOptions ~= {
_.filterNot(o =>
o.startsWith("-X") || o.startsWith("-Y") || o.startsWith("-P:silencer")
)
}
/* TODO: Remove
Test / scalacOptions ~= {
val excluded = Set("-Xfatal-warnings")
_.filterNot(excluded.contains)
}
*/
val filteredScalacOpts: Seq[String] => Seq[String] = {
_.filterNot { opt => opt.startsWith("-X") || opt.startsWith("-Y") }
}
Compile / console / scalacOptions ~= filteredScalacOpts
Test / console / scalacOptions ~= filteredScalacOpts
// Silencer
ThisBuild / libraryDependencies ++= {
if (!scalaBinaryVersion.value.startsWith("3")) {
val silencerVersion = "1.7.17"
Seq(
compilerPlugin(
("com.github.ghik" %% "silencer-plugin" % silencerVersion)
.cross(CrossVersion.full)
),
("com.github.ghik" %% "silencer-lib" % silencerVersion % Provided)
.cross(CrossVersion.full)
)
} else Seq.empty
}