-
Notifications
You must be signed in to change notification settings - Fork 13
/
compiler.sbt
145 lines (124 loc) · 3.06 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
ThisBuild / resolvers ++= (("Tatami Snapshots" at "https://raw.github.com/cchantep/tatami/master/snapshots") +: Resolver
.sonatypeOssRepos("snapshots") ++: Resolver.sonatypeOssRepos("staging"))
ThisBuild / scalaVersion := "2.12.20"
ThisBuild / crossScalaVersions := Seq(
"2.11.12",
scalaVersion.value,
"2.13.15",
"3.4.2"
)
crossVersion := CrossVersion.binary
ThisBuild / scalacOptions ++= Seq(
"-encoding",
"UTF-8",
"-unchecked",
"-deprecation",
"-feature"
)
ThisBuild / scalacOptions ++= {
if (scalaBinaryVersion.value startsWith "2.") {
Seq(
"-Xfatal-warnings",
"-Xlint",
"-g:vars",
"-language:higherKinds"
)
} else Seq.empty
}
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 if (sv != "3") {
Seq("-release", "8", "-Wunused:all", "-language:implicitConversions")
} else {
Seq.empty[String]
}
}
ThisBuild / scalacOptions ++= {
val ver = scalaBinaryVersion.value
if (ver == "2.13") {
Seq(
"-Wconf:msg=.*inferred\\ to\\ be.*(Any|AnyVal|Object).*:is"
)
} else {
Seq.empty
}
}
Compile / console / scalacOptions ~= {
_.filterNot(o =>
o.startsWith("-X") || o.startsWith("-Y") || o.startsWith("-P:silencer")
)
}
Test / compile / 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
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
}
Test / console / scalacOptions += "-Yrepl-class-based"
// Scaladoc
Compile / doc / scalacOptions ++= Opts.doc.title(s"Acolyte ${name.value}")
Compile / doc / scalacOptions ++= {
sbtdynver.DynVerPlugin.autoImport.previousStableVersion.value.map {
_.takeWhile(_ != '.')
}.toSeq
}