forked from monix/monix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
537 lines (466 loc) · 18.2 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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
import com.typesafe.sbt.GitVersioning
import sbt.Keys.version
val allProjects = List(
"execution",
"catnap",
"eval",
"tail",
"reactive",
"java"
)
val benchmarkProjects = List(
"benchmarksPrev",
"benchmarksNext"
).map(_ + "/compile")
addCommandAlias("ci", ";ci-jvm ;ci-js")
addCommandAlias("ci-all", ";ci-jvm ;ci-js ;mimaReportBinaryIssues ;unidoc")
addCommandAlias("ci-js", s";clean ;coreJS/test:compile ;${(allProjects.filter(_ != "java").map(_ + "JS/test") ++ benchmarkProjects).mkString(" ;")}")
addCommandAlias("ci-jvm", s";clean ;coreJVM/test:compile ;${(allProjects.map(_ + "JVM/test") ++ benchmarkProjects).mkString(" ;")}")
addCommandAlias("ci-jvm-mima", s";ci-jvm ;mimaReportBinaryIssues")
addCommandAlias("ci-jvm-all", s";ci-jvm-mima ;unidoc")
addCommandAlias("release", ";project monix ;+clean ;+package ;+publishSigned")
lazy val catsVersion = settingKey[String]("cats version")
ThisBuild/catsVersion := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => "2.0.0"
case _ => "2.1.1"
}
}
lazy val catsEffectVersion = settingKey[String]("cats-effect version")
ThisBuild/catsEffectVersion := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => "2.0.0"
case _ => "2.1.3"
}
}
val jcToolsVersion = "2.1.2"
val reactiveStreamsVersion = "1.0.3"
val minitestVersion = "2.8.2"
val scalaTestVersion = "3.0.8"
val implicitBoxVersion = "0.2.0"
val customScalaJSVersion = Option(System.getenv("SCALAJS_VERSION"))
// The Monix version with which we must keep binary compatibility.
// https://github.com/typesafehub/migration-manager/wiki/Sbt-plugin
val monixSeries = "3.0.0"
lazy val doNotPublishArtifact = Seq(
publishArtifact := false,
publishArtifact in (Compile, packageDoc) := false,
publishArtifact in (Compile, packageSrc) := false,
publishArtifact in (Compile, packageBin) := false
)
lazy val warnUnusedImport = Seq(
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) =>
Seq("-Ywarn-unused-import")
case _ =>
Seq("-Ywarn-unused:imports")
}
},
scalacOptions in (Compile, console) --= Seq("-Ywarn-unused-import", "-Ywarn-unused:imports"),
scalacOptions in Test --= Seq("-Ywarn-unused-import", "-Ywarn-unused:imports")
)
lazy val sharedSettings = warnUnusedImport ++ Seq(
organization := "io.monix",
scalaVersion := "2.13.1",
crossScalaVersions := Seq("2.11.12", "2.12.10", "2.13.1"),
scalacOptions ++= Seq(
// warnings
"-unchecked", // able additional warnings where generated code depends on assumptions
"-deprecation", // emit warning for usages of deprecated APIs
"-feature", // emit warning usages of features that should be imported explicitly
// Features enabled by default
"-language:higherKinds",
"-language:implicitConversions",
"-language:experimental.macros",
),
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
Seq(
// possibly deprecated options
"-Ywarn-inaccessible",
// absolutely necessary for Iterant
"-Ypartial-unification",
)
case _ =>
Seq(
"-Ymacro-annotations",
)
}),
// Linter
scalacOptions ++= Seq(
// Turns all warnings into errors ;-)
"-Xfatal-warnings",
// 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: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
),
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, majorVersion)) if majorVersion <= 12 =>
Seq(
"-Xlint:inaccessible", // warn about inaccessible types in method signatures
"-Xlint:by-name-right-associative", // By-name parameter of right associative operator
"-Xlint:unsound-match" // Pattern match may not be typesafe
)
case _ =>
Seq.empty
}),
// Turning off fatal warnings for ScalaDoc, otherwise we can't release.
scalacOptions in (Compile, doc) ~= (_ filterNot (_ == "-Xfatal-warnings")),
// For working with partially-applied types
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.11.0" cross CrossVersion.full),
// ScalaDoc settings
autoAPIMappings := true,
scalacOptions in ThisBuild ++= 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("[.]$", "")
),
parallelExecution in Test := false,
parallelExecution in IntegrationTest := false,
parallelExecution in ThisBuild := false,
testForkedParallel in Test := false,
testForkedParallel in IntegrationTest := false,
testForkedParallel in ThisBuild := false,
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1),
logBuffered in Test := false,
logBuffered in IntegrationTest := false,
resolvers ++= Seq(
"Typesafe Releases" at "https://repo.typesafe.com/typesafe/releases",
Resolver.sonatypeRepo("releases")
),
// https://github.com/sbt/sbt/issues/2654
incOptions := incOptions.value.withLogRecompileOnMacro(false),
// -- Settings meant for deployment on oss.sonatype.org
sonatypeProfileName := organization.value,
credentials += Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
sys.env.getOrElse("SONATYPE_USER", ""),
sys.env.getOrElse("SONATYPE_PASS", "")
),
publishMavenStyle := true,
publishTo := Some(
if (isSnapshot.value)
Opts.resolver.sonatypeSnapshots
else
Opts.resolver.sonatypeStaging
),
isSnapshot := version.value endsWith "SNAPSHOT",
publishArtifact in Test := false,
pomIncludeRepository := { _ => false }, // removes optional dependencies
licenses := Seq("APL2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
homepage := Some(url("https://monix.io")),
headerLicense := Some(HeaderLicense.Custom(
"""|Copyright (c) 2014-2020 by The Monix Project Developers.
|See the project homepage at: https://monix.io
|
|Licensed under the Apache License, Version 2.0 (the "License");
|you may not use this file except in compliance with the License.
|You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
|Unless required by applicable law or agreed to in writing, software
|distributed under the License is distributed on an "AS IS" BASIS,
|WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|See the License for the specific language governing permissions and
|limitations under the License."""
.stripMargin)),
scmInfo := Some(
ScmInfo(
url("https://github.com/monix/monix"),
"scm:[email protected]:monix/monix.git"
)),
developers := List(
Developer(
id="alexelcu",
name="Alexandru Nedelcu",
email="[email protected]",
url=url("https://alexn.org")
))
)
lazy val crossSettings = sharedSettings ++ Seq(
unmanagedSourceDirectories in Compile += {
baseDirectory.value.getParentFile / "shared" / "src" / "main" / "scala"
},
unmanagedSourceDirectories in Test += {
baseDirectory.value.getParentFile / "shared" / "src" / "test" / "scala"
}
)
def scalaPartV = Def setting (CrossVersion partialVersion scalaVersion.value)
lazy val crossVersionSharedSources: Seq[Setting[_]] =
Seq(Compile, Test).map { sc =>
(unmanagedSourceDirectories in sc) ++= {
(unmanagedSourceDirectories in sc).value.flatMap { dir =>
Seq(
scalaPartV.value match {
case Some((2, y)) if y == 11 => new File(dir.getPath + "_2.11")
case Some((2, y)) if y == 12 => new File(dir.getPath + "_2.12")
case Some((2, y)) if y >= 13 => new File(dir.getPath + "_2.13")
},
scalaPartV.value match {
case Some((2, n)) if n >= 12 => new File(dir.getPath + "_2.12+")
case _ => new File(dir.getPath + "_2.12-")
},
scalaPartV.value match {
case Some((2, n)) if n >= 13 => new File(dir.getPath + "_2.13+")
case _ => new File(dir.getPath + "_2.13-")
},
)
}
}
}
lazy val requiredMacroDeps = Seq(
libraryDependencies ++= Seq(
scalaOrganization.value % "scala-reflect" % scalaVersion.value % Provided,
scalaOrganization.value % "scala-compiler" % scalaVersion.value % Provided
))
lazy val unidocSettings = Seq(
unidocProjectFilter in (ScalaUnidoc, unidoc) :=
inProjects(executionJVM, catnapJVM, evalJVM, tailJVM, reactiveJVM),
// Exclude monix.*.internal from ScalaDoc
sources in (ScalaUnidoc, unidoc) ~= (_ filterNot { file =>
// Exclude all internal Java files from documentation
file.getCanonicalPath matches "^.*monix.+?internal.*?\\.java$"
}),
scalacOptions in (ScalaUnidoc, unidoc) +=
"-Xfatal-warnings",
scalacOptions in (ScalaUnidoc, unidoc) --=
Seq("-Ywarn-unused-import", "-Ywarn-unused:imports"),
scalacOptions in (ScalaUnidoc, unidoc) ++=
Opts.doc.title(s"Monix"),
scalacOptions in (ScalaUnidoc, unidoc) ++=
Opts.doc.sourceUrl(s"https://github.com/monix/monix/tree/v${version.value}€{FILE_PATH}.scala"),
scalacOptions in (ScalaUnidoc, unidoc) ++=
Seq("-doc-root-content", file("rootdoc.txt").getAbsolutePath),
scalacOptions in (ScalaUnidoc, unidoc) ++=
Opts.doc.version(s"${version.value}")
)
lazy val testSettings = Seq(
testFrameworks := Seq(new TestFramework("minitest.runner.Framework")),
libraryDependencies ++= Seq(
"io.monix" %%% "minitest-laws" % minitestVersion % Test,
"org.typelevel" %%% "cats-laws" % catsVersion.value % Test,
"org.typelevel" %%% "cats-effect-laws" % catsEffectVersion.value % Test
)
)
lazy val javaExtensionsSettings = sharedSettings ++ testSettings ++ Seq(
name := "monix-java"
)
lazy val scalaJSSettings = Seq(
coverageExcludedFiles := ".*",
// Use globally accessible (rather than local) source paths in JS source maps
scalacOptions += {
val tagOrHash =
if (isSnapshot.value) git.gitHeadCommit.value.get
else s"v${git.baseVersion.value}"
val l = (baseDirectory in LocalRootProject).value.toURI.toString
val g = s"https://raw.githubusercontent.com/monix/monix/$tagOrHash/"
s"-P:scalajs:mapSourceURI:$l->$g"
}
)
lazy val cmdlineProfile =
sys.env.getOrElse("SBT_PROFILE", "")
def mimaSettings(projectName: String) = Seq(
mimaPreviousArtifacts := Set("io.monix" %% projectName % monixSeries),
mimaBinaryIssueFilters ++= MimaFilters.changesFor_3_0_1,
mimaBinaryIssueFilters ++= MimaFilters.changesFor_3_2_0
)
// https://github.com/lightbend/mima/pull/289
mimaFailOnNoPrevious in ThisBuild := false
def profile: Project ⇒ Project = pr => {
val withCoverage = cmdlineProfile match {
case "coverage" => pr
case _ => pr.disablePlugins(scoverage.ScoverageSbtPlugin)
}
withCoverage.enablePlugins(AutomateHeaderPlugin)
}
lazy val doctestTestSettings = Seq(
doctestTestFramework := DoctestTestFramework.Minitest,
doctestIgnoreRegex := Some(s".*TaskApp.scala|.*reactive.internal.(builders|operators|rstreams).*"),
doctestOnlyCodeBlocksMode := true
)
lazy val monix = project.in(file("."))
.enablePlugins(ScalaUnidocPlugin)
.configure(profile)
.aggregate(coreJVM, coreJS)
.settings(sharedSettings)
.settings(doNotPublishArtifact)
.settings(unidocSettings)
lazy val coreJVM = project.in(file("monix/jvm"))
.configure(profile)
.dependsOn(executionJVM, catnapJVM, evalJVM, tailJVM, reactiveJVM, javaJVM)
.aggregate(executionJVM, catnapJVM, evalJVM, tailJVM, reactiveJVM, javaJVM)
.settings(crossSettings)
.settings(name := "monix")
.settings(
// do not publish second time during +publish run with ScalaJS 1.0
skip.in(publish) := customScalaJSVersion.forall(_.startsWith("1.0"))
)
lazy val coreJS = project.in(file("monix/js"))
.configure(profile)
.enablePlugins(ScalaJSPlugin)
.dependsOn(executionJS, catnapJS, evalJS, tailJS, reactiveJS)
.aggregate(executionJS, catnapJS, evalJS, tailJS, reactiveJS)
.settings(crossSettings)
.settings(scalaJSSettings)
.settings(name := "monix")
lazy val executionCommon = crossVersionSharedSources ++ Seq(
name := "monix-execution",
libraryDependencies += "io.monix" %%% "implicitbox" % implicitBoxVersion
)
lazy val executionJVM = project.in(file("monix-execution/jvm"))
.configure(profile)
.settings(crossSettings)
.settings(testSettings)
.settings(requiredMacroDeps)
.settings(executionCommon)
.settings(libraryDependencies += "org.jctools" % "jctools-core" % jcToolsVersion)
.settings(libraryDependencies += "org.reactivestreams" % "reactive-streams" % reactiveStreamsVersion)
.settings(mimaSettings("monix-execution"))
lazy val executionJS = project.in(file("monix-execution/js"))
.enablePlugins(ScalaJSPlugin)
.configure(profile)
.settings(crossSettings)
.settings(scalaJSSettings)
.settings(testSettings)
.settings(requiredMacroDeps)
.settings(executionCommon)
lazy val catnapCommon =
crossSettings ++ crossVersionSharedSources ++ testSettings ++ Seq(
name := "monix-catnap",
libraryDependencies += "org.typelevel" %%% "cats-effect" % catsEffectVersion.value
)
lazy val catnapJVM = project.in(file("monix-catnap/jvm"))
.configure(profile)
.dependsOn(executionJVM % "compile->compile; test->test")
.settings(catnapCommon)
.settings(mimaSettings("monix-catnap"))
.settings(doctestTestSettings)
lazy val catnapJS = project.in(file("monix-catnap/js"))
.enablePlugins(ScalaJSPlugin)
.configure(profile)
.dependsOn(executionJS % "compile->compile; test->test")
.settings(scalaJSSettings)
.settings(catnapCommon)
lazy val evalCommon =
crossSettings ++ crossVersionSharedSources ++ testSettings ++
Seq(
name := "monix-eval"
)
lazy val evalJVM = project.in(file("monix-eval/jvm"))
.configure(profile)
.dependsOn(executionJVM % "compile->compile; test->test")
.dependsOn(catnapJVM)
.settings(evalCommon)
.settings(mimaSettings("monix-eval"))
.settings(doctestTestSettings)
lazy val evalJS = project.in(file("monix-eval/js"))
.enablePlugins(ScalaJSPlugin)
.configure(profile)
.dependsOn(executionJS % "compile->compile; test->test")
.dependsOn(catnapJS)
.settings(scalaJSSettings)
.settings(evalCommon)
lazy val tailCommon =
crossSettings ++ testSettings ++ Seq(
name := "monix-tail"
)
lazy val tailJVM = project.in(file("monix-tail/jvm"))
.configure(profile)
.dependsOn(evalJVM % "test->test")
.dependsOn(catnapJVM)
.settings(tailCommon)
.settings(doctestTestSettings)
.settings(mimaSettings("monix-tail"))
lazy val tailJS = project.in(file("monix-tail/js"))
.enablePlugins(ScalaJSPlugin)
.configure(profile)
.dependsOn(evalJS % "test->test")
.dependsOn(catnapJS)
.settings(scalaJSSettings)
.settings(tailCommon)
lazy val reactiveCommon =
crossSettings ++ testSettings ++ Seq(
name := "monix-reactive"
)
lazy val reactiveJVM = project.in(file("monix-reactive/jvm"))
.configure(profile)
.dependsOn(executionJVM, evalJVM % "compile->compile; test->test")
.settings(reactiveCommon)
.settings(mimaSettings("monix-reactive"))
.settings(doctestTestSettings)
lazy val reactiveJS = project.in(file("monix-reactive/js"))
.enablePlugins(ScalaJSPlugin)
.configure(profile)
.dependsOn(executionJS, evalJS % "compile->compile; test->test")
.settings(reactiveCommon)
.settings(scalaJSSettings)
lazy val javaJVM = project.in(file("monix-java"))
.configure(profile)
.dependsOn(executionJVM % "provided->compile; test->test")
.dependsOn(evalJVM % "provided->compile; test->test")
.settings(javaExtensionsSettings)
lazy val reactiveTests = project.in(file("reactiveTests"))
.configure(profile)
.dependsOn(coreJVM)
.settings(sharedSettings)
.settings(doNotPublishArtifact)
.settings(
libraryDependencies ++= Seq(
"org.reactivestreams" % "reactive-streams-tck" % reactiveStreamsVersion % Test,
"org.scalatest" %% "scalatest" % scalaTestVersion % Test
))
lazy val benchmarksPrev = project.in(file("benchmarks/vprev"))
.configure(profile)
.enablePlugins(JmhPlugin)
.settings(crossSettings)
.settings(sharedSettings)
.settings(doNotPublishArtifact)
.settings(
libraryDependencies ++= Seq(
"io.monix" %% "monix" % "3.2.0",
"dev.zio" %% "zio" % "1.0.0-RC18-2"
))
lazy val benchmarksNext = project.in(file("benchmarks/vnext"))
.configure(profile)
.dependsOn(coreJVM)
.enablePlugins(JmhPlugin)
.settings(crossSettings)
.settings(sharedSettings)
.settings(doNotPublishArtifact)
.settings(
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % "1.0.0-RC18-2"
))
//------------- For Release
enablePlugins(GitVersioning)
/* The BaseVersion setting represents the in-development (upcoming) version,
* as an alternative to SNAPSHOTS.
*/
git.baseVersion := "3.3.0"
val ReleaseTag = """^v(\d+\.\d+(?:\.\d+(?:[-.]\w+)?)?)$""".r
git.gitTagToVersionNumber := {
case ReleaseTag(v) => Some(v)
case _ => None
}
git.formattedShaVersion := {
val suffix = git.makeUncommittedSignifierSuffix(git.gitUncommittedChanges.value, git.uncommittedSignifier.value)
git.gitHeadCommit.value map { _.substring(0, 7) } map { sha =>
git.baseVersion.value + "-" + sha + suffix
}
}