forked from typelevel/cats-effect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
477 lines (409 loc) · 16.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
/*
* Copyright (c) 2017-2019 The Typelevel Cats-effect Project Developers
*
* 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.
*/
import microsites.ExtraMdFileConfig
import scala.sys.process._
import scala.xml.Elem
import scala.xml.transform.{RewriteRule, RuleTransformer}
import sbtcrossproject.crossProject
organization in ThisBuild := "org.typelevel"
organizationName in ThisBuild := "Typelevel"
startYear in ThisBuild := Some(2017)
val CompileTime = config("CompileTime").hide
val SimulacrumVersion = "0.15.0"
val CatsVersion = "1.6.0"
val ScalaTestVersion = Def.setting{
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
"3.0.5"
case _ =>
"3.0.6-SNAP5"
}
}
val ScalaCheckVersion = Def.setting{
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
"1.13.5"
case _ =>
"1.14.0"
}
}
val DisciplineVersion = Def.setting{
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
"0.9.0"
case _ =>
"0.10.0"
}
}
addCommandAlias("ci", ";test ;mimaReportBinaryIssues; doc")
addCommandAlias("release", ";project root ;reload ;+publishSigned ;sonatypeReleaseAll ;microsite/publishMicrosite")
val commonSettings = Seq(
scalaVersion := "2.12.8",
crossScalaVersions := Seq("2.11.12", "2.12.8", "2.13.0-M5"),
//todo: re-enable disable scaladoc on 2.13 due to https://github.com/scala/bug/issues/11045
sources in (Compile, doc) := (
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
(sources in (Compile, doc)).value
case _ =>
Nil
}
),
scalacOptions ++= PartialFunction.condOpt(CrossVersion.partialVersion(scalaVersion.value)) {
case Some((2, n)) if n >= 13 =>
Seq(
"-Ymacro-annotations"
)
}.toList.flatten,
scalacOptions in (Compile, console) ~= (_ filterNot Set("-Xfatal-warnings", "-Ywarn-unused-import").contains),
scalacOptions in (Compile, doc) ++= {
val isSnapshot = git.gitCurrentTags.value.map(git.gitTagToVersionNumber.value).flatten.isEmpty
val path = if (isSnapshot)
scmInfo.value.get.browseUrl + "/blob/" + git.gitHeadCommit.value.get + "€{FILE_PATH}.scala"
else
scmInfo.value.get.browseUrl + "/blob/v" + version.value + "€{FILE_PATH}.scala"
Seq("-doc-source-url", path, "-sourcepath", baseDirectory.in(LocalRootProject).value.getAbsolutePath)
},
sources in (Compile, doc) :=
(sources in (Compile, doc)).value,
scalacOptions in (Compile, doc) ++=
Seq("-doc-root-content", (baseDirectory.value.getParentFile / "shared" / "rootdoc.txt").getAbsolutePath),
scalacOptions in (Compile, doc) ++=
Opts.doc.title("cats-effect"),
// Disable parallel execution in tests; otherwise we cannot test System.err
parallelExecution in Test := false,
parallelExecution in IntegrationTest := false,
testForkedParallel in Test := false,
testForkedParallel in IntegrationTest := false,
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1),
// credit: https://github.com/typelevel/cats/pull/1638
ivyConfigurations += CompileTime,
unmanagedClasspath in Compile ++= update.value.select(configurationFilter("CompileTime")),
logBuffered in Test := false,
isSnapshot := version.value endsWith "SNAPSHOT", // so… sonatype doesn't like git hash snapshots
publishTo := Some(
if (isSnapshot.value)
Opts.resolver.sonatypeSnapshots
else
Opts.resolver.sonatypeStaging),
publishMavenStyle := true,
pomIncludeRepository := { _ => false },
sonatypeProfileName := organization.value,
pomExtra :=
<developers>
<developer>
<id>djspiewak</id>
<name>Daniel Spiewak</name>
<url>http://www.codecommit.com</url>
</developer>
<developer>
<id>mpilquist</id>
<name>Michael Pilquist</name>
<url>https://github.com/mpilquist</url>
</developer>
<developer>
<id>alexelcu</id>
<name>Alexandru Nedelcu</name>
<url>https://alexn.org</url>
</developer>
</developers>,
homepage := Some(url("https://typelevel.org/cats-effect/")),
scmInfo := Some(ScmInfo(url("https://github.com/typelevel/cats-effect"), "[email protected]:typelevel/cats-effect.git")),
headerLicense := Some(HeaderLicense.Custom(
"""|Copyright (c) 2017-2019 The Typelevel Cats-effect Project Developers
|
|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)),
// For evicting Scoverage out of the generated POM
// See: https://github.com/scoverage/sbt-scoverage/issues/153
pomPostProcess := { (node: xml.Node) =>
new RuleTransformer(new RewriteRule {
override def transform(node: xml.Node): Seq[xml.Node] = node match {
case e: Elem
if e.label == "dependency" && e.child.exists(child => child.label == "groupId" && child.text == "org.scoverage") => Nil
case _ => Seq(node)
}
}).transform(node).head
},
addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.9" cross CrossVersion.binary)
)
val mimaSettings = Seq(
mimaPreviousArtifacts := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) => Set(organization.value % (name.value + "_2.13.0-M4") % "1.0.0")
case _ => Set(organization.value %% name.value % "1.0.0")
}
},
mimaBinaryIssueFilters ++= {
import com.typesafe.tools.mima.core._
import com.typesafe.tools.mima.core.ProblemFilters._
Seq(
// Ignore any binary compatibility issues/problems that match the internals package
exclude[Problem]("cats.effect.internals.*"),
// All internals - https://github.com/typelevel/cats-effect/pull/403
exclude[DirectMissingMethodProblem]("cats.effect.concurrent.Semaphore#AbstractSemaphore.awaitGate"),
exclude[DirectMissingMethodProblem]("cats.effect.concurrent.Semaphore#AsyncSemaphore.awaitGate"),
exclude[DirectMissingMethodProblem]("cats.effect.concurrent.Semaphore#ConcurrentSemaphore.awaitGate"),
// All internals — https://github.com/typelevel/cats-effect/pull/424
exclude[MissingClassProblem]("cats.effect.concurrent.Deferred$UncancelabbleDeferred"),
// Laws - https://github.com/typelevel/cats-effect/pull/473
exclude[ReversedMissingMethodProblem]("cats.effect.laws.AsyncLaws.repeatedAsyncFEvaluationNotMemoized"),
exclude[ReversedMissingMethodProblem]("cats.effect.laws.BracketLaws.bracketPropagatesTransformerEffects"),
exclude[ReversedMissingMethodProblem]("cats.effect.laws.discipline.BracketTests.bracketTrans")
)
})
lazy val cmdlineProfile = sys.env.getOrElse("SBT_PROFILE", "")
def profile: Project => Project = pr => cmdlineProfile match {
case "coverage" => pr
case _ => pr.disablePlugins(scoverage.ScoverageSbtPlugin)
}
lazy val scalaJSSettings = Seq(
coverageExcludedFiles := ".*",
// Use globally accessible (rather than local) source paths in JS source maps
scalacOptions += {
val hasVersion = git.gitCurrentTags.value.map(git.gitTagToVersionNumber.value).flatten.nonEmpty
val versionOrHash =
if (hasVersion)
s"v${version.value}"
else
git.gitHeadCommit.value.get
val l = (baseDirectory in LocalRootProject).value.toURI.toString
val g = s"https://raw.githubusercontent.com/typelevel/cats-effect/$versionOrHash/"
s"-P:scalajs:mapSourceURI:$l->$g"
})
lazy val skipOnPublishSettings = Seq(
skip in publish := true,
publish := (()),
publishLocal := (()),
publishArtifact := false,
publishTo := None)
lazy val sharedSourcesSettings = Seq(
unmanagedSourceDirectories in Compile += {
baseDirectory.value.getParentFile / "shared" / "src" / "main" / "scala"
},
unmanagedSourceDirectories in Test += {
baseDirectory.value.getParentFile / "shared" / "src" / "test" / "scala"
})
lazy val root = project.in(file("."))
.aggregate(coreJVM, coreJS, lawsJVM, lawsJS)
.configure(profile)
.settings(skipOnPublishSettings)
lazy val core = crossProject(JSPlatform, JVMPlatform).in(file("core"))
.settings(commonSettings: _*)
.settings(
name := "cats-effect",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % CatsVersion,
"com.github.mpilquist" %%% "simulacrum" % SimulacrumVersion % CompileTime,
"org.typelevel" %%% "cats-laws" % CatsVersion % "test",
"org.scalatest" %%% "scalatest" % ScalaTestVersion.value % "test",
"org.scalacheck" %%% "scalacheck" % ScalaCheckVersion.value % "test",
"org.typelevel" %%% "discipline" % DisciplineVersion.value % "test"),
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 =>
Seq(
compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full)
)
case _ =>
// if scala 2.13.0-M4 or later, macro annotations merged into scala-reflect
// https://github.com/scala/scala/pull/6606
Nil
}
})
.jvmConfigure(_.enablePlugins(AutomateHeaderPlugin))
.jvmConfigure(_.settings(mimaSettings))
.jsConfigure(_.enablePlugins(AutomateHeaderPlugin))
.jvmConfigure(profile)
.jsConfigure(_.settings(scalaJSSettings))
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val laws = crossProject(JSPlatform, JVMPlatform)
.in(file("laws"))
.dependsOn(core % "compile->compile;test->test")
.settings(commonSettings: _*)
.settings(
name := "cats-effect-laws",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-laws" % CatsVersion,
"org.scalacheck" %%% "scalacheck" % ScalaCheckVersion.value,
"org.typelevel" %%% "discipline" % DisciplineVersion.value,
"org.scalatest" %%% "scalatest" % ScalaTestVersion.value % "test"))
.jvmConfigure(_.enablePlugins(AutomateHeaderPlugin))
.jvmConfigure(_.settings(mimaSettings))
.jsConfigure(_.enablePlugins(AutomateHeaderPlugin))
.jvmConfigure(profile)
.jsConfigure(_.settings(scalaJSSettings))
lazy val lawsJVM = laws.jvm
lazy val lawsJS = laws.js
lazy val benchmarksPrev = project.in(file("benchmarks/vPrev"))
.configure(profile)
.settings(commonSettings ++ skipOnPublishSettings ++ sharedSourcesSettings)
.settings(libraryDependencies += "org.typelevel" %% "cats-effect" % "1.0.0-RC")
.settings(scalacOptions ~= (_ filterNot Set("-Xfatal-warnings", "-Ywarn-unused-import").contains))
.enablePlugins(JmhPlugin)
lazy val benchmarksNext = project.in(file("benchmarks/vNext"))
.configure(profile)
.dependsOn(coreJVM)
.settings(commonSettings ++ skipOnPublishSettings ++ sharedSourcesSettings)
.settings(scalacOptions ~= (_ filterNot Set("-Xfatal-warnings", "-Ywarn-unused-import").contains))
.enablePlugins(JmhPlugin)
lazy val docsMappingsAPIDir =
settingKey[String]("Name of subdirectory in site target directory for api docs")
lazy val siteSettings = Seq(
micrositeName := "Cats Effect",
micrositeDescription := "The IO Monad for Scala",
micrositeAuthor := "Cats Effect contributors",
micrositeGithubOwner := "typelevel",
micrositeGithubRepo := "cats-effect",
micrositeBaseUrl := "/cats-effect",
micrositeTwitterCreator := "@typelevel",
micrositeDocumentationUrl := "https://typelevel.org/cats-effect/api/",
micrositeFooterText := None,
micrositeHighlightTheme := "atom-one-light",
micrositePalette := Map(
"brand-primary" -> "#3e5b95",
"brand-secondary" -> "#294066",
"brand-tertiary" -> "#2d5799",
"gray-dark" -> "#49494B",
"gray" -> "#7B7B7E",
"gray-light" -> "#E5E5E6",
"gray-lighter" -> "#F4F3F4",
"white-color" -> "#FFFFFF"),
micrositeExtraMdFiles := Map(
file("README.md") -> ExtraMdFileConfig(
"index.md",
"home",
Map("section" -> "home", "position" -> "0")
)
),
fork in tut := true,
scalacOptions in Tut ~= (_ filterNot Set(
"-Xfatal-warnings",
"-Ywarn-numeric-widen",
"-Ywarn-unused:imports",
"-Ywarn-unused:locals",
"-Ywarn-unused:patvars",
"-Ywarn-unused:privates",
"-Ywarn-numeric-widen",
"-Ywarn-dead-code",
"-Xlint:-missing-interpolator,_").contains),
docsMappingsAPIDir := "api",
addMappingsToSiteDir(mappings in packageDoc in Compile in coreJVM, docsMappingsAPIDir)
)
lazy val microsite = project.in(file("site"))
.enablePlugins(MicrositesPlugin)
.enablePlugins(SiteScaladocPlugin)
.settings(commonSettings ++ skipOnPublishSettings ++ sharedSourcesSettings)
.settings(siteSettings)
.dependsOn(coreJVM, lawsJVM)
/*
* Compatibility version. Use this to declare what version with
* which `master` remains in compatibility. This is literally
* backwards from how -SNAPSHOT versioning works, but it avoids
* the need to pre-declare (before work is done) what kind of
* compatibility properties the next version will have (i.e. major
* or minor bump).
*
* As an example, the builds of a project might go something like
* this:
*
* - 0.1-hash1
* - 0.1-hash2
* - 0.1-hash3
* - 0.1
* - 0.1-hash1
* - 0.2-hash2
* - 0.2
* - 0.2-hash1
* - 0.2-hash2
* - 1.0-hash3
* - 1.0-hash4
* - 1.0
*
* The value of BaseVersion starts at 0.1 and remains there until
* compatibility with the 0.1 line is lost, which happens just
* prior to the release of 0.2. Then the base version again remains
* 0.2-compatible until that compatibility is broken, with the major
* version bump of 1.0. Again, this is all to avoid pre-committing
* to a major/minor bump before the work is done (see: Scala 2.8).
*/
val BaseVersion = "1.0.0"
licenses in ThisBuild += ("Apache-2.0", url("http://www.apache.org/licenses/"))
/***********************************************************************\
Boilerplate below these lines
\***********************************************************************/
coursierUseSbtCredentials in ThisBuild := true
coursierChecksums in ThisBuild := Nil // workaround for nexus sync bugs
// Adapted from Rob Norris' post at https://tpolecat.github.io/2014/04/11/scalac-flags.html
scalacOptions in ThisBuild ++= Seq(
"-language:_",
"-deprecation",
"-encoding", "UTF-8", // yes, this is 2 args
"-feature",
"-unchecked",
"-Ywarn-dead-code"
)
scalacOptions in ThisBuild ++= (
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v <= 12 => Seq(
"-Xfatal-warnings",
"-Yno-adapted-args",
"-Ypartial-unification"
)
case _ =>
Nil
}
)
scalacOptions in ThisBuild ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => Seq(
"-Ywarn-numeric-widen",
"-Ywarn-unused:imports",
"-Ywarn-unused:locals",
"-Ywarn-unused:patvars",
"-Ywarn-unused:privates",
"-Xlint:-missing-interpolator,-unused,_"
)
case _ =>
Seq("-Xlint:-missing-interpolator,_")
}
}
scalacOptions in Test += "-Yrangepos"
useGpg := true
enablePlugins(GitVersioning)
val ReleaseTag = """^v(\d+\.\d+(?:\.\d+(?:[-.]\w+)?)?)$""".r
git.baseVersion := BaseVersion
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
}
}