This repository has been archived by the owner on May 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.sbt
316 lines (285 loc) · 13.1 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
import scoverage._
import sbt._
import Keys._
// shadow sbt-scalajs' definition
import sbtcrossproject.CrossPlugin.autoImport.crossProject
val monocleVersion = "2.0.0"
val scalazVersion = "7.2.29"
val spireVersion = "0.14.1"
val silencerVersion = "1.4.2"
publishTo in ThisBuild := {
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")
}
val sonataCredentials = for {
username <- sys.env.get("SONATYPE_USERNAME")
password <- sys.env.get("SONATYPE_PASSWORD")
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)
credentials in ThisBuild ++= sonataCredentials.toSeq
val standardSettings = Seq(
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseCrossBuild := true,
logBuffered in Compile := false,
logBuffered in Test := false,
updateOptions := updateOptions.value.withCachedResolution(true),
exportJars := true,
organization := "org.scalaz",
organizationName := "Scalaz",
startYear := Some(2018),
ScoverageKeys.coverageHighlighting := true,
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
Seq(
"-Xfuture", // Turn on future language features.
"-Xlint:by-name-right-associative", // By-name parameter of right associative operator.
"-Xlint:nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
"-Xlint:unsound-match", // Pattern match may not be typesafe.
"-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver.
"-Ypartial-unification", // Enable partial unification in type constructor inference
"-Ywarn-inaccessible", // Warn about inaccessible types in method signatures.
"-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`.
"-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
"-Ywarn-nullary-unit", // Warn when nullary methods return Unit.
"-opt-warnings:_", // Warn if a method call marked @inline cannot be inlined
)
case _ =>
Nil
}
},
scalacOptions ++= Seq(
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-encoding", "utf-8", // Specify character encoding used by source files.
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-language:existentials", // Existential types (besides wildcard types) can be written and inferred
"-language:experimental.macros", // Allow macro definition (besides implementation and application)
"-language:higherKinds", // Allow higher-kinded types
"-language:implicitConversions", // Allow definition of implicit functions called views
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
"-Xfatal-warnings", // Fail the compilation if there are any warnings.
"-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver.
"-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error.
"-Xlint:delayedinit-select", // Selecting member of DelayedInit.
"-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element.
"-Xlint:inaccessible", // Warn about inaccessible types in method signatures.
"-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:nullary-unit", // Warn when nullary methods return Unit.
"-Xlint:option-implicit", // Option.apply used implicit view.
"-Xlint:package-object-classes", // Class or object defined in package object.
"-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds.
"-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field.
"-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component.
"-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope.
"-Ywarn-dead-code", // Warn when dead code is identified.
"-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined.
"-Ywarn-numeric-widen", // Warn when numerics are widened.
"-Ywarn-unused:implicits", // Warn if an implicit parameter is unused.
"-Ywarn-unused:imports", // Warn if an import selector is not referenced.
"-Ywarn-unused:locals", // Warn if a local definition is unused.
"-Ywarn-unused:params", // Warn if a value parameter is unused.
"-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused.
"-Ywarn-unused:privates", // Warn if a private member is unused.
"-Ywarn-value-discard", // Warn when non-Unit expression results are unused.
"-opt:l:inline", // Enable the optimizer
"-opt-inline-from:<sources>",
"-Yopt-inline-heuristics:at-inline-annotated",
),
scalacOptions in (Compile, doc) ++= Seq("-groups", "-implicits"),
wartremoverWarnings in (Compile, compile) --= Seq(
Wart.PublicInference, // TODO: enable incrementally — currently results in many errors
Wart.ImplicitParameter), // see wartremover/wartremover#350 & #351
licenses += ("BSD New" -> new URL("https://opensource.org/licenses/BSD-3-Clause")),
headerLicense := Some(HeaderLicense.BSD3Clause("2018", "Edmund Noble")),
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3"))
val publishSettings = Seq(
organizationHomepage := None,
homepage := Some(url("https://github.com/scalaz/testz")),
scmInfo := Some(
ScmInfo(
url("https://github.com/scalaz/testz"),
"scm:git@github.com:scalaz/testz.git")),
developers := List(
sbt.Developer(
id = "edmundnoble",
name = "Edmund Noble",
email = "edmundnoble@gmail.com",
url = url("https://github.com/edmundnoble")
)
))
val core = crossProject(JSPlatform, JVMPlatform).in(file("core"))
.settings(name := "testz-core")
.settings(standardSettings ++ publishSettings)
.settings(
connectInput in run := true,
outputStrategy := Some(StdoutOutput)
)
.enablePlugins(AutomateHeaderPlugin)
val coreJVM = core.jvm
val coreJS = core.js
val util = crossProject(JSPlatform, JVMPlatform).in(file("util"))
.settings(name := "testz-util")
.settings(standardSettings ++ publishSettings)
.enablePlugins(AutomateHeaderPlugin)
val utilJVM = util.jvm
val utilJS = util.js
val resource = crossProject(JSPlatform, JVMPlatform).in(file("resource"))
.dependsOn(core, util)
.settings(name := "testz-resource")
.settings(standardSettings ++ publishSettings)
val resourceJVM = resource.jvm
val resourceJS = resource.js
val runner = crossProject(JSPlatform, JVMPlatform).in(file("runner"))
.dependsOn(core, util)
.settings(name := "testz-runner")
.settings(standardSettings ++ publishSettings)
.enablePlugins(AutomateHeaderPlugin)
val runnerJVM = runner.jvm
val runnerJS = runner.js
val stdlib = crossProject(JSPlatform, JVMPlatform).in(file("stdlib"))
.dependsOn(core, resource, runner, util)
.settings(name := "testz-stdlib")
.settings(standardSettings ++ publishSettings)
.settings(
libraryDependencies ++= Seq(
compilerPlugin("com.github.ghik" %% "silencer-plugin" % silencerVersion),
"com.github.ghik" %% "silencer-lib" % silencerVersion % Provided
)
)
.enablePlugins(AutomateHeaderPlugin)
val stdlibJVM = stdlib.jvm
val stdlibJS = stdlib.js
val scalatest = crossProject(JSPlatform, JVMPlatform).in(file("scalatest"))
.dependsOn(core)
.settings(name := "testz-scalatest")
.settings(standardSettings ++ publishSettings)
.enablePlugins(AutomateHeaderPlugin)
val scalatestJVM = scalatest.jvm
val scalatestJS = scalatest.js
val scalaz = project.in(file("scalaz"))
.dependsOn(coreJVM, resourceJVM, runnerJVM)
.settings(name := "testz-scalaz")
.settings(standardSettings ++ publishSettings)
.settings(
libraryDependencies ++= Seq(
"org.scalaz" %%% "scalaz-concurrent" % scalazVersion % "compile, test",
"org.scalaz" %%% "scalaz-core" % scalazVersion % "compile, test"
)
)
.enablePlugins(AutomateHeaderPlugin)
val specs2 = crossProject(JSPlatform, JVMPlatform).in(file("specs2"))
.dependsOn(core)
.settings(name := "testz-specs2")
.settings(standardSettings ++ publishSettings)
.settings(
libraryDependencies ++= Seq(
"org.specs2" %%% "specs2-core" % "4.8.0"
)
)
.enablePlugins(AutomateHeaderPlugin)
val specs2JVM = specs2.jvm
val specs2JS = specs2.js
val extras = crossProject(JSPlatform, JVMPlatform).in(file("extras"))
.dependsOn(core, resource, stdlib)
.settings(name := "testz-extras")
.settings(standardSettings ++ publishSettings)
.enablePlugins(AutomateHeaderPlugin)
val extrasJVM = extras.jvm
val extrasJS = extras.js
val tests = project.in(file("tests"))
.settings(name := "testz-tests")
.dependsOn(coreJVM, extrasJVM, resourceJVM, runnerJVM, scalatestJVM, scalaz, specs2JVM, stdlibJVM)
.settings(standardSettings ++ publishSettings)
.settings(libraryDependencies ++= Seq(
"com.github.julien-truffaut" %% "monocle-law" % monocleVersion % Test))
.enablePlugins(AutomateHeaderPlugin)
val benchmarks = project.in(file("benchmarks"))
.dependsOn(coreJVM, runnerJVM, scalatestJVM, scalaz, stdlibJVM, specs2JVM)
.settings(name := "testz-benchmarks")
.settings(skip in publish := true)
.settings(standardSettings)
.enablePlugins(AutomateHeaderPlugin)
.enablePlugins(JmhPlugin)
/** A project just for the console.
* Applies only the settings necessary for that purpose.
*/
val repl = project
.dependsOn(tests % "compile->test")
.dependsOn(benchmarks)
.settings(standardSettings)
.settings(skip in publish := true)
.settings((compile in ThisBuild) := sbt.internal.inc.Analysis.Empty) // sbt.inc.Analysis.empty)
.settings(
console := (console in Test).value,
scalacOptions --= Seq("-Yno-imports", "-Ywarn-unused:imports", "-Xfatal-warnings"),
initialCommands in console += """
|import testz._
|import testz.benchmarks._
|import testz.extras._
|import testz.runner._
|import testz.z._, z.streaming._
|import scalaz._, scalaz.Scalaz._
""".stripMargin.trim
)
val docs = project
.settings(name := "testz-docs")
.dependsOn(
benchmarks, coreJVM, extrasJVM, runnerJVM, scalatestJVM, scalaz, specs2JVM, stdlibJVM, utilJVM
)
.settings(standardSettings)
.settings(skip in publish := true)
.enablePlugins(MicrositesPlugin)
.settings(
// TIL, tut is run in a real REPL
scalacOptions --= Seq("-Yno-imports", "-Ywarn-unused:imports", "-Xfatal-warnings")
)
.settings(
// https://github.com/47deg/sbt-microsites/issues/305
libraryDependencies ~= (_.filterNot(m => m.organization == "org.scalameta" && m.name.startsWith("mdoc"))),
micrositeName := "testz",
micrositeDescription := "Purely functional testing for Scala",
micrositeAuthor := "Edmund Noble",
micrositeGithubOwner := "scalaz",
micrositeGithubRepo := "testz",
micrositeDocumentationUrl := "/testz/docs/01-first-example.html",
micrositeFavicons := Seq(microsites.MicrositeFavicon("favicon.png", "512x512")),
micrositeBaseUrl := "/testz",
micrositePalette := Map(
"brand-primary" -> "#ED2124",
"brand-secondary" -> "#251605",
"brand-tertiary" -> "#491119",
"gray-dark" -> "#453E46",
"gray" -> "#837F84",
"gray-light" -> "#E3E2E3",
"gray-lighter" -> "#F4F3F4",
"white-color" -> "#FFFFFF"
),
micrositePushSiteWith := GitHub4s,
micrositeGithubToken := sys.env.get("GITHUB_TOKEN"),
)
val root = Project("root", file("."))
.settings(name := "testz")
.settings(standardSettings)
.settings(skip in publish := true)
.settings(console := (console in repl).value)
.aggregate(
benchmarks,
coreJVM, coreJS,
docs,
extrasJVM, extrasJS,
repl,
resourceJVM, resourceJS,
runnerJVM, runnerJS,
scalatestJVM, scalatestJS,
scalaz,
specs2JVM, specs2JS,
stdlibJVM, stdlibJS,
tests,
utilJVM, utilJS
)
.enablePlugins(AutomateHeaderPlugin)