-
Notifications
You must be signed in to change notification settings - Fork 21
/
build.sbt
260 lines (244 loc) · 8.93 KB
/
build.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/*
* Scala (https://www.scala-lang.org)
*
* Copyright EPFL and Lightbend, Inc.
*
* Licensed under Apache License 2.0
* (http://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
import sbt._
import org.scalajs.sbtplugin.ScalaJSPlugin
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
// shadow sbt-scalajs' crossProject and CrossType until we drop Scala.js 0.6 from the crossbuild
import sbtcrossproject.{ crossProject, CrossType }
addCommandAlias("ci-all", ";+clean ;+test:compile ;+test ;+package")
addCommandAlias("release", ";+clean ;+verifyNative/clean ;+publishSigned ;+verifyNative/publishSigned")
val Scala211 = "2.11.12"
val Scala212 = "2.12.19"
val Scala213 = "2.13.13"
val Scala3 = "3.1.3"
val Scala31 = "3.1.3"
ThisBuild / scalaVersion := Scala212
ThisBuild / organization := "com.eed3si9n.verify"
ThisBuild / homepage := Some(url("https://www.scala-lang.org"))
ThisBuild / startYear := Some(2002)
ThisBuild / licenses += (("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0")))
ThisBuild / headerLicense := Some(
HeaderLicense.Custom(
s"""Scala (${(ThisBuild / homepage).value.get})
|
|Copyright EPFL and Lightbend, Inc.
|
|Licensed under Apache License 2.0
|(http://www.apache.org/licenses/LICENSE-2.0).
|
|See the NOTICE file distributed with this work for
|additional information regarding copyright ownership.
|""".stripMargin
)
)
val ReleaseTag = """^v(\d+\.\d+\.\d+(?:[-.]\w+)?)$""".r
lazy val verifyRoot = (project in file("."))
.aggregate(verifyJVM, verifyJS, verifyNative)
.settings(
name := "verify root",
Compile / sources := Nil,
publish / skip := true,
crossScalaVersions := Nil
)
lazy val verify = (crossProject(JVMPlatform, JSPlatform, NativePlatform) in file("."))
.settings(
name := "verify",
sharedSettings,
crossVersionSharedSources,
libraryDependencies ++= {
val crossVer = CrossVersion.partialVersion(scalaVersion.value)
crossVer match {
case Some((2, _)) =>
List(
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Compile,
"org.scala-lang" % "scala-compiler" % scalaVersion.value % Provided
)
case _ => Nil
}
}
)
.jvmSettings(
crossScalaVersions := Seq(Scala211, Scala212, Scala213, Scala3),
libraryDependencies += "org.scala-sbt" % "test-interface" % "1.0"
)
.jsSettings(
crossScalaVersions := Seq(Scala211, Scala212, Scala213, Scala3),
libraryDependencies ++= {
val sv = scalaBinaryVersion.value
if (sv.startsWith("3"))
// https://github.com/portable-scala/portable-scala-reflect/issues/23
Seq(
"org.portable-scala" % "portable-scala-reflect_sjs1_2.13" % "1.1.2",
"org.scala-js" % "scalajs-test-interface_2.13" % scalaJSVersion
)
else
Seq(
"org.portable-scala" %%% "portable-scala-reflect" % "1.1.2",
"org.scala-js" %% "scalajs-test-interface" % scalaJSVersion
)
},
Test / scalaJSStage := FastOptStage
)
.nativeSettings(
libraryDependencies ++= Seq(
"org.scala-native" %%% "test-interface" % nativeVersion
),
libraryDependencies ++= {
if (scalaBinaryVersion.value != "3") {
Seq(
compilerPlugin(
"com.github.ghik" % "silencer-plugin" % "1.7.16" cross CrossVersion.full
)
)
} else {
Nil
}
},
libraryDependencies += {
if (scalaBinaryVersion.value == "3") {
"com.github.ghik" % "silencer-lib_2.13.7" % "1.17.13" % Provided
} else {
"com.github.ghik" % "silencer-lib" % "1.7.16" % Provided cross CrossVersion.full // required for 0.3.9 support
}
},
crossScalaVersions := Seq(Scala212, Scala213, Scala31),
publishConfiguration := publishConfiguration.value.withOverwrite(true),
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true)
)
lazy val verifyJVM = verify.jvm
lazy val verifyJS = verify.js
lazy val verifyNative = verify.native
def scalaPartV = Def.setting(CrossVersion partialVersion scalaVersion.value)
lazy val crossVersionSharedSources: Seq[Setting[_]] =
(Seq(Compile, Test).map { sc =>
(sc / unmanagedSourceDirectories) ++= {
(sc / unmanagedSourceDirectories).value.map { dir =>
scalaPartV.value match {
case Some((major, minor)) =>
new File(dir.getPath + s"_$major.$minor")
case None =>
throw new NoSuchElementException("Scala version")
}
}
}
}) ++ Seq(
Compile / unmanagedSourceDirectories += {
val crossVer = CrossVersion.partialVersion(scalaVersion.value)
crossVer match {
case Some((2, _)) => baseDirectory.value.getParentFile / "shared" / "src" / "main" / "scala-2"
case _ => baseDirectory.value.getParentFile / "shared" / "src" / "main" / "scala-3"
}
}
)
lazy val scalaLinterOptions =
Seq(
// Enables linter options
"-Xlint:adapted-args", // warn if an argument list is modified to match the receiver
"-Xlint:nullary-unit", // warn when nullary methods return Unit
"-Xlint:inaccessible", // warn about inaccessible types in method signatures
"-Xlint:nullary-override", // warn when non-nullary `def f()' overrides nullary `def f'
"-Xlint:infer-any", // warn when a type argument is inferred to be `Any`
"-Xlint:missing-interpolator", // a string literal appears to be missing an interpolator id
"-Xlint:doc-detached", // a ScalaDoc comment appears to be detached from its element
"-Xlint:private-shadow", // a private field (or class parameter) shadows a superclass field
"-Xlint:type-parameter-shadow", // a local type parameter shadows a type already in scope
"-Xlint:poly-implicit-overload", // parameterized overloaded implicit methods are not visible as view bounds
"-Xlint:option-implicit", // Option.apply used implicit view
"-Xlint:delayedinit-select", // Selecting member of DelayedInit
"-Xlint:package-object-classes" // Class or object defined in package object
)
lazy val scalaTwoTwelveDeprecatedOptions =
Seq(
// Deprecated in 2.12, removed in 2.13
"-Ywarn-inaccessible",
"-Ywarn-nullary-override",
"-Ywarn-nullary-unit"
)
lazy val sharedSettings = Seq(
ThisBuild / scalacOptions ++= Seq(
// Note, this is used by the doc-source-url feature to determine the
// relative path of a given source file. If it's not a prefix of a the
// absolute path of the source file, the absolute path of that file
// will be put into the FILE_SOURCE variable, which is
// definitely not what we want.
"-sourcepath",
file(".").getAbsolutePath.replaceAll("[.]$", "")
),
scalacOptions ++= Seq(
"-unchecked",
"-deprecation",
"-feature",
"-Xlint",
"-Ywarn-dead-code",
"-Xlog-free-terms"
),
// Version specific options
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v > 12 =>
scalaLinterOptions ++ Seq("-Wunused:-implicits", "-Xfatal-warnings")
case Some((2, 12)) =>
scalaLinterOptions ++ scalaTwoTwelveDeprecatedOptions ++ Seq("-Ywarn-unused:-implicits", "-Xfatal-warnings")
case Some((2, 11)) =>
scalaLinterOptions ++ Seq("-target:jvm-1.8") ++ scalaTwoTwelveDeprecatedOptions
case _ =>
Seq("-target:jvm-1.8")
}),
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11 | 12)) =>
Seq(
"-Xlint:unsound-match", // Pattern match may not be typesafe
"-Xlint:by-name-right-associative", // By-name parameter of right associative operator
"-Ywarn-adapted-args"
)
case _ =>
Nil
}),
resolvers ++= Seq(
"Typesafe Releases" at "https://repo.typesafe.com/typesafe/releases"
),
testFrameworks := Seq(new TestFramework("verify.runner.Framework")),
headerLicense := (ThisBuild / headerLicense).value
)
ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/scala/nanotest-strawman"),
"scm:[email protected]:scala/nanotest-strawman.git"
)
)
ThisBuild / developers := List(
Developer(
id = "alexelcu",
name = "Alexandru Nedelcu",
email = "[email protected]",
url = url("https://alexn.org")
),
Developer(
id = "eed3i9n",
name = "Eugene Yokota",
email = "@eed3si9n",
url = url("https://eed3si9n.com")
)
)
// -- Settings meant for deployment on oss.sonatype.org
ThisBuild / publishMavenStyle := true
ThisBuild / publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
ThisBuild / isSnapshot := {
(ThisBuild / version).value endsWith "SNAPSHOT"
}
ThisBuild / Test / publishArtifact := false
ThisBuild / pomIncludeRepository := { _ => false } // removes optional dependencies