forked from typelevel/fs2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
430 lines (402 loc) · 15.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
import microsites.ExtraMdFileConfig
import com.typesafe.tools.mima.core._
import sbtrelease.Version
import sbtcrossproject.crossProject
val ReleaseTag = """^release/([\d\.]+a?)$""".r
addCommandAlias("fmt", "; compile:scalafmt; test:scalafmt; it:scalafmt; scalafmtSbt")
addCommandAlias(
"fmtCheck",
"; compile:scalafmtCheck; test:scalafmtCheck; it:scalafmtCheck; scalafmtSbtCheck"
)
crossScalaVersions in ThisBuild := Seq("2.13.2", "2.12.10")
scalaVersion in ThisBuild := crossScalaVersions.value.head
githubWorkflowJavaVersions in ThisBuild := Seq("adopt@1.11")
githubWorkflowPublishTargetBranches in ThisBuild := Seq(RefPredicate.Equals(Ref.Branch("main")))
githubWorkflowBuild in ThisBuild := Seq(
WorkflowStep.Sbt(List("fmtCheck", "compile")),
WorkflowStep.Sbt(List("testJVM")),
WorkflowStep.Sbt(List("testJS")),
WorkflowStep.Sbt(List("doc", "mimaReportBinaryIssues")),
WorkflowStep.Sbt(List(";project coreJVM;it:test"))
)
githubWorkflowEnv in ThisBuild ++= Map(
"SONATYPE_USERNAME" -> "fs2-ci",
"SONATYPE_PASSWORD" -> s"$${{ secrets.SONATYPE_PASSWORD }}"
)
lazy val contributors = Seq(
"pchiusano" -> "Paul Chiusano",
"pchlupacek" -> "Pavel Chlupáček",
"SystemFw" -> "Fabio Labella",
"alissapajer" -> "Alissa Pajer",
"djspiewak" -> "Daniel Spiewak",
"fthomas" -> "Frank Thomas",
"runarorama" -> "Rúnar Ó. Bjarnason",
"jedws" -> "Jed Wesley-Smith",
"mpilquist" -> "Michael Pilquist",
"durban" -> "Daniel Urban"
)
lazy val commonSettingsBase = Seq(
organization := "co.fs2",
scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-language:implicitConversions,higherKinds",
"-Xfatal-warnings"
) ++
(scalaBinaryVersion.value match {
case v if v.startsWith("2.13") =>
List("-Xlint", "-Ywarn-unused")
case v if v.startsWith("2.12") =>
List("-Ypartial-unification")
case other => sys.error(s"Unsupported scala version: $other")
}),
scalacOptions in (Compile, console) ~= {
_.filterNot("-Ywarn-unused" == _)
.filterNot("-Xlint" == _)
.filterNot("-Xfatal-warnings" == _)
},
// Disable fatal warnings for test compilation because sbt-doctest generated tests
// generate warnings which lead to test failures.
scalacOptions in (Test, compile) ~= {
_.filterNot("-Xfatal-warnings" == _)
},
scalacOptions in (Compile, console) += "-Ydelambdafy:inline",
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value,
javaOptions in (Test, run) ++= Seq("-Xms64m", "-Xmx64m"),
libraryDependencies ++= Seq(
compilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3"),
"org.typelevel" %%% "cats-core" % "2.1.1",
"org.typelevel" %%% "cats-laws" % "2.1.1" % "test",
"org.typelevel" %%% "cats-effect" % "2.1.4",
"org.typelevel" %%% "cats-effect-laws" % "2.1.4" % "test",
"org.scalacheck" %%% "scalacheck" % "1.14.3" % "test",
"org.scalameta" %%% "munit-scalacheck" % "0.7.9" % "test"
),
testFrameworks += new TestFramework("munit.Framework"),
scmInfo := Some(
ScmInfo(
url("https://github.com/functional-streams-for-scala/fs2"),
"git@github.com:functional-streams-for-scala/fs2.git"
)
),
homepage := Some(url("https://github.com/functional-streams-for-scala/fs2")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
initialCommands := s"""
import fs2._, cats.effect._, cats.effect.implicits._, cats.implicits._
import scala.concurrent.ExecutionContext.Implicits.global, scala.concurrent.duration._
implicit val contextShiftIO: ContextShift[IO] = IO.contextShift(global)
implicit val timerIO: Timer[IO] = IO.timer(global)
""",
doctestTestFramework := DoctestTestFramework.ScalaCheck
) ++ scaladocSettings ++ publishingSettings ++ releaseSettings
lazy val commonSettings = commonSettingsBase ++ testSettings
lazy val crossCommonSettings = commonSettingsBase ++ crossTestSettings
lazy val commonTestSettings = Seq(
javaOptions in Test ++= (Seq(
"-Dscala.concurrent.context.minThreads=8",
"-Dscala.concurrent.context.numThreads=8",
"-Dscala.concurrent.context.maxThreads=8"
) ++ (sys.props.get("fs2.test.travis") match {
case Some(value) =>
Seq(s"-Dfs2.test.travis=true")
case None => Seq()
})),
parallelExecution in Test := false,
publishArtifact in Test := true
)
lazy val testSettings =
(fork in Test := true) +:
commonTestSettings
lazy val crossTestSettings =
(fork in Test := crossProjectPlatform.value != JSPlatform) +:
commonTestSettings
lazy val mdocSettings = Seq(
scalacOptions in Compile ~= {
_.filterNot("-Ywarn-unused-import" == _)
.filterNot("-Ywarn-unused" == _)
.filterNot("-Xlint" == _)
.filterNot("-Xfatal-warnings" == _)
},
scalacOptions in Compile += "-Ydelambdafy:inline"
)
def scmBranch(v: String): String = {
val Some(ver) = Version(v)
if (ver.qualifier.exists(_ == "-SNAPSHOT"))
// support branch (0.9.0-SNAPSHOT -> series/0.9)
s"series/${ver.copy(subversions = ver.subversions.take(1), qualifier = None).string}"
else
// release tag (0.9.0-M2 -> v0.9.0-M2)
s"v${ver.string}"
}
lazy val scaladocSettings = Seq(
scalacOptions in (Compile, doc) ++= Seq(
"-doc-source-url",
s"${scmInfo.value.get.browseUrl}/tree/${scmBranch(version.value)}€{FILE_PATH}.scala",
"-sourcepath",
baseDirectory.in(LocalRootProject).value.getAbsolutePath,
"-implicits",
"-implicits-sound-shadowing",
"-implicits-show-all"
),
scalacOptions in (Compile, doc) ~= { _.filterNot(_ == "-Xfatal-warnings") },
autoAPIMappings := true
)
lazy val publishingSettings = Seq(
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim.endsWith("SNAPSHOT"))
Some("snapshots".at(nexus + "content/repositories/snapshots"))
else
Some("releases".at(nexus + "service/local/staging/deploy/maven2"))
},
credentials ++= (for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
username,
password
)).toSeq,
publishMavenStyle := true,
pomIncludeRepository := { _ => false },
pomExtra := {
<developers>
{
for ((username, name) <- contributors)
yield <developer>
<id>{username}</id>
<name>{name}</name>
<url>http://github.com/{username}</url>
</developer>
}
</developers>
},
pomPostProcess := { node =>
import scala.xml._
import scala.xml.transform._
def stripIf(f: Node => Boolean) =
new RewriteRule {
override def transform(n: Node) =
if (f(n)) NodeSeq.Empty else n
}
val stripTestScope = stripIf(n => n.label == "dependency" && (n \ "scope").text == "test")
new RuleTransformer(stripTestScope).transform(node)(0)
},
gpgWarnOnFailure := version.value.endsWith("SNAPSHOT")
)
lazy val commonJsSettings = Seq(
scalaJSLinkerConfig ~= { config =>
// https://github.com/scala-js/scala-js/issues/2798
try {
scala.util.Properties.isJavaAtLeast("1.8")
config
} catch {
case _: NumberFormatException =>
config.withParallel(false)
}
},
scalaJSStage in Test := FastOptStage,
jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(),
scalacOptions in Compile += {
val dir = project.base.toURI.toString.replaceFirst("[^/]+/?$", "")
val url =
"https://raw.githubusercontent.com/functional-streams-for-scala/fs2"
s"-P:scalajs:mapSourceURI:$dir->$url/${scmBranch(version.value)}/"
},
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule))
)
lazy val noPublish = Seq(
publish := {},
publishLocal := {},
publishArtifact := false
)
lazy val releaseSettings = Seq(
releaseCrossBuild := true
)
lazy val mimaSettings = Seq(
mimaPreviousArtifacts := {
List("2.0.0", "2.3.0").map { pv =>
organization.value % (normalizedName.value + "_" + scalaBinaryVersion.value) % pv
}.toSet
},
mimaBinaryIssueFilters ++= Seq(
// These methods were only used internally between Stream and Pull: they were private to fs2.
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.Stream.fromFreeC"),
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.Stream.get$extension"),
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.Stream#IdOps.self$extension"),
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.Pull.get$extension"),
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.Pull.get"),
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.Stream.get$extension"),
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.Stream.get"),
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.Pull.fromFreeC"),
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.Pull.get$extension"),
// No bincompat on internal package
ProblemFilters.exclude[Problem]("fs2.internal.*"),
// Mima reports all ScalaSignature changes as errors, despite the fact that they don't cause bincompat issues when version swapping (see https://github.com/lightbend/mima/issues/361)
ProblemFilters.exclude[IncompatibleSignatureProblem]("*"),
// .to(sink) syntax was removed in 1.0.2 and has been hidden in all 2.x releases behind private[fs2], hence it's safe to remove
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.Stream.to"),
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.Stream.to$extension"),
ProblemFilters.exclude[DirectMissingMethodProblem](
"fs2.interop.reactivestreams.StreamSubscriber#FSM.stream"
), // FSM is package private
ProblemFilters.exclude[Problem]("fs2.io.tls.TLSEngine.*"), // private[fs2] type
ProblemFilters.exclude[Problem]("fs2.io.tls.TLSEngine#*"),
ProblemFilters.exclude[DirectMissingMethodProblem](
"fs2.io.tls.TLSSocket.fs2$io$tls$TLSSocket$$binding$default$2"
),
ProblemFilters.exclude[DirectMissingMethodProblem](
"fs2.io.tls.TLSSocket.fs2$io$tls$TLSSocket$$binding$default$3"
),
// InputOutputBuffer is private[tls]
ProblemFilters.exclude[DirectMissingMethodProblem]("fs2.io.tls.InputOutputBuffer.output"),
ProblemFilters.exclude[ReversedMissingMethodProblem]("fs2.io.tls.InputOutputBuffer.output")
)
)
lazy val root = project
.in(file("."))
.disablePlugins(MimaPlugin)
.settings(commonSettings)
.settings(mimaSettings)
.settings(noPublish)
.aggregate(coreJVM, coreJS, io, reactiveStreams, benchmark, experimental, microsite)
lazy val IntegrationTest = config("it").extend(Test)
lazy val core = crossProject(JVMPlatform, JSPlatform)
.in(file("core"))
.configs(IntegrationTest)
.settings(Defaults.itSettings: _*)
.settings(
inConfig(IntegrationTest)(org.scalafmt.sbt.ScalafmtPlugin.scalafmtConfigSettings)
)
.settings(crossCommonSettings: _*)
.settings(
name := "fs2-core",
sourceDirectories in (Compile, scalafmt) += baseDirectory.value / "../shared/src/main/scala",
libraryDependencies += "org.scodec" %%% "scodec-bits" % "1.1.17"
)
.jsSettings(commonJsSettings: _*)
lazy val coreJVM = core.jvm
.enablePlugins(SbtOsgi)
.settings(
OsgiKeys.exportPackage := Seq("fs2.*"),
OsgiKeys.privatePackage := Seq(),
OsgiKeys.importPackage := {
val Some((major, minor)) = CrossVersion.partialVersion(scalaVersion.value)
Seq(s"""scala.*;version="[$major.$minor,$major.${minor + 1})"""", "*")
},
OsgiKeys.additionalHeaders := Map("-removeheaders" -> "Include-Resource,Private-Package"),
osgiSettings
)
.settings(mimaSettings)
lazy val coreJS = core.js.disablePlugins(DoctestPlugin, MimaPlugin)
lazy val io = project
.in(file("io"))
.enablePlugins(SbtOsgi)
.settings(commonSettings)
.settings(mimaSettings)
.settings(
name := "fs2-io",
OsgiKeys.exportPackage := Seq("fs2.io.*"),
OsgiKeys.privatePackage := Seq(),
OsgiKeys.importPackage := {
val Some((major, minor)) = CrossVersion.partialVersion(scalaVersion.value)
Seq(
s"""scala.*;version="[$major.$minor,$major.${minor + 1})"""",
"""fs2.*;version="${Bundle-Version}"""",
"*"
)
},
OsgiKeys.additionalHeaders := Map("-removeheaders" -> "Include-Resource,Private-Package"),
osgiSettings
)
.dependsOn(coreJVM % "compile->compile;test->test")
lazy val reactiveStreams = project
.in(file("reactive-streams"))
.enablePlugins(SbtOsgi)
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"org.reactivestreams" % "reactive-streams" % "1.0.3",
"org.reactivestreams" % "reactive-streams-tck" % "1.0.3" % "test",
"org.scalatestplus" %% "testng-6-7" % "3.2.0.0" % "test"
)
)
.settings(mimaSettings)
.settings(
name := "fs2-reactive-streams",
OsgiKeys.exportPackage := Seq("fs2.interop.reactivestreams.*"),
OsgiKeys.privatePackage := Seq(),
OsgiKeys.importPackage := {
val Some((major, minor)) = CrossVersion.partialVersion(scalaVersion.value)
Seq(
s"""scala.*;version="[$major.$minor,$major.${minor + 1})"""",
"""fs2.*;version="${Bundle-Version}"""",
"*"
)
},
OsgiKeys.additionalHeaders := Map("-removeheaders" -> "Include-Resource,Private-Package"),
osgiSettings
)
.dependsOn(coreJVM % "compile->compile;test->test")
lazy val benchmark = project
.in(file("benchmark"))
.disablePlugins(MimaPlugin)
.settings(commonSettings)
.settings(noPublish)
.settings(
name := "fs2-benchmark",
javaOptions in (Test, run) := (javaOptions in (Test, run)).value
.filterNot(o => o.startsWith("-Xmx") || o.startsWith("-Xms")) ++ Seq("-Xms256m", "-Xmx256m")
)
.enablePlugins(JmhPlugin)
.dependsOn(io)
lazy val microsite = project
.in(file("site"))
.enablePlugins(MicrositesPlugin)
.disablePlugins(MimaPlugin)
.settings(commonSettings)
.settings(noPublish)
.settings(
micrositeName := "fs2",
micrositeDescription := "Purely functional, effectful, resource-safe, concurrent streams for Scala",
micrositeGithubOwner := "functional-streams-for-scala",
micrositeGithubRepo := "fs2",
micrositePushSiteWith := GitHub4s,
micrositeGithubToken := sys.env.get("GITHUB_TOKEN"),
micrositeBaseUrl := "",
micrositeHighlightTheme := "atom-one-light",
micrositeExtraMdFilesOutput := resourceManaged.value / "main" / "jekyll",
micrositeExtraMdFiles := Map(
file("README.md") -> ExtraMdFileConfig(
"index.md",
"home",
Map("title" -> "Home", "section" -> "home", "position" -> "0")
)
)
)
.settings(mdocSettings)
.dependsOn(coreJVM, io, reactiveStreams)
lazy val experimental = project
.in(file("experimental"))
.enablePlugins(SbtOsgi)
.settings(commonSettings)
.settings(mimaSettings)
.settings(
name := "fs2-experimental",
OsgiKeys.exportPackage := Seq("fs2.experimental.*"),
OsgiKeys.privatePackage := Seq(),
OsgiKeys.importPackage := {
val Some((major, minor)) = CrossVersion.partialVersion(scalaVersion.value)
Seq(
s"""scala.*;version="[$major.$minor,$major.${minor + 1})"""",
"""fs2.*;version="${Bundle-Version}"""",
"*"
)
},
OsgiKeys.additionalHeaders := Map("-removeheaders" -> "Include-Resource,Private-Package"),
osgiSettings
)
.dependsOn(coreJVM % "compile->compile;test->test")
addCommandAlias("testJVM", ";coreJVM/test;io/test;reactiveStreams/test;benchmark/test")
addCommandAlias("testJS", "coreJS/test")