-
Notifications
You must be signed in to change notification settings - Fork 13
/
compiler.sbt
122 lines (104 loc) · 2.71 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
ThisBuild / resolvers ++= (("Tatami Snapshots" at "https://raw.github.com/cchantep/tatami/master/snapshots") +: Resolver
.sonatypeOssRepos("snapshots") ++: Resolver.sonatypeOssRepos("staging"))
ThisBuild / scalaVersion := "2.12.17"
ThisBuild / crossScalaVersions := Seq(
"2.11.12",
scalaVersion.value,
"2.13.8",
"3.2.2"
)
crossVersion := CrossVersion.binary
ThisBuild / scalacOptions ++= Seq(
"-encoding",
"UTF-8",
"-unchecked",
"-deprecation",
"-feature"
)
ThisBuild / scalacOptions ++= {
if (scalaBinaryVersion.value startsWith "2.") {
Seq(
"-Xfatal-warnings",
"-target:jvm-1.8",
"-Xlint",
"-g:vars",
"-language:higherKinds"
)
} else Seq.empty
}
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 if (sv != "3") {
Seq("-Wunused:all", "-language:implicitConversions")
} else {
Seq.empty[String]
}
}
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
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
}
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
}