-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbuild.sbt
More file actions
358 lines (330 loc) · 10.4 KB
/
build.sbt
File metadata and controls
358 lines (330 loc) · 10.4 KB
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
import ReleaseTransformations._
import org.scalafmt.sbt.ScalafmtPlugin.scalafmtConfigSettings
import sbtcrossproject.{CrossType, crossProject}
import scala.xml.{Elem, Node => XmlNode, NodeSeq => XmlNodeSeq}
import scala.xml.transform.{RewriteRule, RuleTransformer}
ThisBuild / organization := "io.iteratee"
ThisBuild / crossScalaVersions := List("2.12.14", "2.13.6", "3.0.2")
ThisBuild / scalaVersion := crossScalaVersions.value.last
ThisBuild / githubWorkflowJavaVersions := Seq("adopt@1.8")
ThisBuild / githubWorkflowPublishTargetBranches := Nil
ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(
List(
"clean",
"coverage",
"scalastyle",
"scalafmtCheckAll",
"scalafmtSbtCheck",
"test",
"coverageReport"
),
id = None,
name = Some("Test")
),
WorkflowStep.Use(
UseRef.Public("codecov", "codecov-action", "v1")
)
)
val compilerOptions = Seq(
"-deprecation",
"-encoding",
"UTF-8",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-unchecked",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-unused-import",
"-Xfuture"
)
val catsVersion = "2.6.1"
val catsEffectVersion = "3.2.9"
val fs2Version = "3.1.5"
val scalaTestVersion = "3.2.10"
val scalaCheckVersion = "1.15.4"
val disciplineVersion = "1.1.5"
/**
* Some terrible hacks to work around Cats's decision to have builds for different Scala versions depend on different
* versions of Discipline, etc.
*/
def priorTo2_13(scalaVersion: String): Boolean =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, minor)) if minor < 13 => true
case _ => false
}
lazy val previousIterateeVersion = "0.19.0"
val docMappingsApiDir = settingKey[String]("Subdirectory in site target directory for API docs")
lazy val baseSettings = Seq(
scalacOptions ++= {
if (priorTo2_13(scalaVersion.value)) compilerOptions
else
compilerOptions.flatMap {
case "-Ywarn-unused-import" => Some("-Ywarn-unused:imports")
case "-Yno-adapted-args" => None
case "-Xfuture" => None
case other => Some(other)
}
},
scalacOptions += "-Yno-predef",
Compile / console / scalacOptions := {
if (priorTo2_13(scalaVersion.value)) compilerOptions
else
compilerOptions.flatMap {
case "-Ywarn-unused-import" => Some("-Ywarn-unused:imports")
case "-Yno-adapted-args" => None
case "-Xfuture" => None
case other => Some(other)
}
},
Test / compile / scalacOptions := {
if (priorTo2_13(scalaVersion.value)) compilerOptions
else
compilerOptions.flatMap {
case "-Ywarn-unused-import" => Some("-Ywarn-unused:imports")
case "-Yno-adapted-args" => None
case "-Xfuture" => None
case other => Some(other)
}
},
scalacOptions ++= {
if (scalaVersion.value.startsWith("3")) Seq("-Ykind-projector:underscores")
else Seq("-Xsource:3", "-P:kind-projector:underscore-placeholders")
},
coverageHighlighting := true,
coverageEnabled := {
if (scalaVersion.value.startsWith("3")) false else coverageEnabled.value
},
Compile / scalastyleSources ++= (Compile / sourceDirectories).value,
libraryDependencies ++= {
if (scalaVersion.value.startsWith("3")) Nil
else
Seq(
compilerPlugin(("org.typelevel" %% "kind-projector" % "0.13.2").cross(CrossVersion.full))
)
}
)
lazy val allSettings = baseSettings ++ publishSettings
lazy val commonJsSettings = Seq(
Global / scalaJSStage := FastOptStage
)
lazy val docSettings = Seq(
docMappingsApiDir := "api",
addMappingsToSiteDir(ScalaUnidoc / packageDoc / mappings, docMappingsApiDir),
ScalaUnidoc / unidoc / scalacOptions ++= Seq(
"-groups",
"-implicits",
"-doc-source-url",
scmInfo.value.get.browseUrl + "/tree/main€{FILE_PATH}.scala",
"-sourcepath",
(LocalRootProject / baseDirectory).value.getAbsolutePath
),
git.remoteRepo := "git@github.com:travisbrown/iteratee.git",
ScalaUnidoc / unidoc / unidocProjectFilter :=
inAnyProject -- inProjects(coreJS, benchmark, testingJS, testsJVM, testsJS)
)
lazy val iteratee = project
.in(file("."))
.enablePlugins(GhpagesPlugin, ScalaUnidocPlugin)
.settings(allSettings)
.settings(docSettings)
.settings(noPublishSettings)
.aggregate(coreJVM, coreJS, files, testingJVM, testingJS, testsJVM, testsJS, benchmark)
.dependsOn(coreJVM, files)
lazy val core = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("core"))
.settings(
moduleName := "iteratee-core",
name := "core"
)
.settings(allSettings: _*)
.settings(
libraryDependencies += "org.typelevel" %%% "cats-core" % catsVersion
)
.jvmSettings(
mimaPreviousArtifacts := Set("io.iteratee" %% "iteratee-core" % previousIterateeVersion)
)
.jsSettings(commonJsSettings: _*)
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val testing = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Full)
.in(file("testing"))
.settings(
moduleName := "iteratee-testing",
name := "testing"
)
.settings(allSettings: _*)
.settings(
libraryDependencies ++= Seq(
"org.scalacheck" %%% "scalacheck" % scalaCheckVersion,
"org.scalatest" %%% "scalatest" % scalaTestVersion,
"org.scalatestplus" %%% "scalacheck-1-15" % "3.2.10.0",
"org.typelevel" %%% "cats-laws" % catsVersion,
"org.typelevel" %%% "discipline-core" % disciplineVersion
),
coverageExcludedPackages := "io\\.iteratee\\.testing\\..*"
)
.jsSettings(commonJsSettings: _*)
.jvmConfigure(_.dependsOn(files))
.dependsOn(core)
lazy val testingJVM = testing.jvm
lazy val testingJS = testing.js
lazy val tests = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Full)
.in(file("tests"))
.configs(IntegrationTest)
.settings(
moduleName := "iteratee-tests",
name := "tests"
)
.settings(allSettings: _*)
.settings(noPublishSettings: _*)
.settings(Defaults.itSettings: _*)
.settings(inConfig(IntegrationTest)(scalafmtConfigSettings))
.settings(
libraryDependencies ++= Seq(
"org.scalacheck" %%% "scalacheck" % scalaCheckVersion,
"org.scalatest" %%% "scalatest" % scalaTestVersion,
"org.scalatestplus" %%% "scalacheck-1-15" % "3.2.10.0",
"org.typelevel" %%% "cats-laws" % catsVersion,
"org.typelevel" %%% "discipline-core" % disciplineVersion
),
scalacOptions ~= {
_.filterNot(Set("-Yno-predef"))
},
coverageExcludedPackages := "io\\.iteratee\\.tests\\..*"
)
.jvmSettings(
fork := false,
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect-laws" % catsEffectVersion % "it"
)
)
.jsSettings(commonJsSettings: _*)
.jsSettings(
Test / test := {}
)
.jvmConfigure(_.dependsOn(files))
.dependsOn(testing)
lazy val testsJVM = tests.jvm
lazy val testsJS = tests.js
lazy val files = project
.settings(
moduleName := "iteratee-files",
mimaPreviousArtifacts := Set("io.iteratee" %% "iteratee-files" % previousIterateeVersion),
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % catsEffectVersion
)
)
.settings(allSettings)
.dependsOn(coreJVM)
lazy val benchmark = project
.configs(IntegrationTest)
.settings(
moduleName := "iteratee-benchmark"
)
.settings(allSettings ++ Defaults.itSettings)
.settings(inConfig(IntegrationTest)(scalafmtConfigSettings))
.settings(noPublishSettings)
.settings(
libraryDependencies ++= Seq(
"co.fs2" %% "fs2-core" % fs2Version,
"org.scalatest" %% "scalatest" % scalaTestVersion % Test,
"org.typelevel" %% "cats-free" % catsVersion
)
)
.enablePlugins(JmhPlugin)
.dependsOn(coreJVM, testsJVM)
lazy val publishSettings = Seq(
releaseCrossBuild := true,
releaseVcsSign := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
homepage := Some(url("https://github.com/travisbrown/iteratee")),
licenses := Seq("Apache 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
publishMavenStyle := true,
Test / publishArtifact := false,
pomIncludeRepository := { _ =>
false
},
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"))
},
autoAPIMappings := true,
apiURL := Some(url("https://travisbrown.github.io/iteratee/api/")),
scmInfo := Some(
ScmInfo(
url("https://github.com/travisbrown/iteratee"),
"scm:git:git@github.com:travisbrown/iteratee.git"
)
),
developers := List(
Developer(
"travisbrown",
"Travis Brown",
"travisrobertbrown@gmail.com",
url("https://twitter.com/travisbrown")
)
),
pomPostProcess := { (node: XmlNode) =>
new RuleTransformer(
new RewriteRule {
private def isTestScope(elem: Elem): Boolean =
elem.label == "dependency" && elem.child.exists(child => child.label == "scope" && child.text == "test")
override def transform(node: XmlNode): XmlNodeSeq = node match {
case elem: Elem if isTestScope(elem) => Nil
case _ => node
}
}
).transform(node).head
}
)
lazy val noPublishSettings = Seq(
publish := {},
publishLocal := {},
publishArtifact := false
)
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
val jvmProjects = Seq(
"benchmark",
"core",
"files",
"testing",
"tests"
)
val jsProjects = Seq(
"coreJS",
"testingJS",
"testsJS"
)
addCommandAlias("testJVM", jvmProjects.map(";" + _ + "/test").mkString)
addCommandAlias(
"validateJVM",
";testJVM;tests/it:test;scalafmtCheck;scalafmtSbtCheck;test:scalafmtCheck;it:scalafmtCheck;scalastyle;unidoc"
)
addCommandAlias("testJS", jsProjects.map(";" + _ + "/test").mkString)
addCommandAlias(
"validateJS",
";testJS;scalafmtCheck;scalafmtSbtCheck;test:scalafmtCheck;it:scalafmtCheck;scalastyle;unidoc"
)
addCommandAlias("validate", ";validateJVM;validateJS")