forked from ReactiveMongo/ReactiveMongo-BSON
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompiler.sbt
More file actions
136 lines (121 loc) · 3.17 KB
/
compiler.sbt
File metadata and controls
136 lines (121 loc) · 3.17 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
ThisBuild / scalaVersion := "2.12.20"
ThisBuild / crossScalaVersions := Seq(
"2.11.12",
scalaVersion.value,
"2.13.15",
"3.6.3"
)
crossVersion := CrossVersion.binary
ThisBuild / scalacOptions ++= Seq(
"-encoding",
"UTF-8",
"-unchecked",
"-deprecation",
"-feature"
// "-Xfatal-warnings"
)
ThisBuild / scalacOptions ++= {
if (scalaBinaryVersion.value startsWith "2.") {
Seq(
"-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(
"-target:jvm-1.8",
"-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(
"-target:jvm-1.8",
"-Xmax-classfile-name",
"128",
"-Yopt:_",
"-Ydead-code",
"-Yclosure-elim",
"-Yconst-opt"
)
} else if (sv == "2.13") {
Seq(
"-release",
"8",
"-explaintypes",
// "-Werror",
"-Wnumeric-widen",
"-Wdead-code",
"-Wvalue-discard",
"-Wextra-implicit",
"-Wmacros:after",
"-Wunused"
)
} else {
Seq("-release", "8", "-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 ++= {
val v = scalaBinaryVersion.value
if (!v.startsWith("3")) {
val silencerVersion: String = {
if (v == "2.11") {
"1.17.13"
} else {
"1.7.19"
}
}
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.") {
if (ver == "2.13") {
Seq(
"-Wconf:msg=.*inferred\\ to\\ be.*(Any|Object).*:is",
"-Wconf:msg=.*parameter\\ macro(Val|Doc)\\ .*is\\ never\\ used:is",
"-Wconf:msg=.*pattern\\ var\\ macro.*\\ is\\ never\\ used:is",
"-Wconf:msg=.*bh\\ .*MacroSpec.*:is",
"-Wconf:msg=.*local\\ type\\ Opts\\ is\\ never.*:is",
"-Wconf:msg=.*WithImplicit2\\ .*never\\ used.*:is"
)
} else {
Seq("-P:silencer:globalFilters=.*value\\ macro.*\\ is never used;class\\ Response\\ in\\ package\\ protocol\\ is\\ deprecated;pattern\\ var\\ macro.*\\ is\\ never\\ used")
}
} else Seq.empty
}