-
Notifications
You must be signed in to change notification settings - Fork 11
/
compiler.sbt
119 lines (104 loc) · 2.68 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
ThisBuild / scalaVersion := "2.12.17"
ThisBuild / crossScalaVersions := Seq(
"2.11.12",
scalaVersion.value,
"2.13.10",
"3.4.2"
)
crossVersion := CrossVersion.binary
ThisBuild / scalacOptions ++= Seq(
"-encoding",
"UTF-8",
"-unchecked",
"-deprecation",
"-feature",
"-Xfatal-warnings"
)
ThisBuild / scalacOptions ++= {
if (scalaBinaryVersion.value startsWith "2.") {
Seq(
"-target:jvm-1.8",
"-Xlint",
"-g:vars"
)
} else Seq(
"-Wconf:msg=.*should\\ not\\ .*infix\\ operator.*:s",
"-Wconf:msg=.*vararg\\ splices.*:s",
"-Wconf:msg=.*with\\ as\\ a\\ type\\ operator.*:s",
"-Wconf:msg=.*deprecated\\ for\\ wildcard\\ arguments.*:s"
)
}
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")
}
}
Compile / console / scalacOptions ~= {
_.filterNot(o =>
o.startsWith("-X") || o.startsWith("-Y") || o.startsWith("-P:silencer")
)
}
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.17.13"
Seq(
compilerPlugin(
("com.github.ghik" %% "silencer-plugin" % silencerVersion)
.cross(CrossVersion.full)
),
("com.github.ghik" %% "silencer-lib" % silencerVersion % Provided)
.cross(CrossVersion.full)
)
} else Seq.empty
}
ThisBuild / scalacOptions ++= {
val ver = scalaBinaryVersion.value
if (ver startsWith "2.") {
val base =
"-P:silencer:globalFilters=.*value\\ macro.*\\ is never used;class\\ Response\\ in\\ package\\ protocol\\ is\\ deprecated;pattern\\ var\\ macro.*\\ is\\ never\\ used"
if (ver == "2.13") {
Seq(s"${base};a\\ type\\ was\\ inferred\\ to\\ be.*(Any|Object).*")
} else {
Seq(base)
}
} else Seq.empty
}