forked from fd4s/fs2-kafka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
311 lines (279 loc) · 8.88 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
val catsEffectVersion = "2.1.2"
val catsVersion = "2.1.2"
val confluentVersion = "5.4.1"
val embeddedKafkaVersion = "2.4.1"
val fs2Version = "2.3.0"
val kafkaVersion = "2.4.1"
val vulcanVersion = "1.0.1"
val scala212 = "2.12.10"
val scala213 = "2.13.1"
lazy val `fs2-kafka` = project
.in(file("."))
.settings(
mimaSettings,
scalaSettings,
noPublishSettings,
console := (console in (core, Compile)).value,
console in Test := (console in (core, Test)).value
)
.aggregate(core, vulcan)
lazy val core = project
.in(file("modules/core"))
.settings(
moduleName := "fs2-kafka",
name := moduleName.value,
dependencySettings ++ Seq(
libraryDependencies ++= Seq(
"co.fs2" %% "fs2-core" % fs2Version,
"org.apache.kafka" % "kafka-clients" % kafkaVersion
)
),
publishSettings,
mimaSettings,
scalaSettings,
testSettings
)
lazy val vulcan = project
.in(file("modules/vulcan"))
.settings(
moduleName := "fs2-kafka-vulcan",
name := moduleName.value,
dependencySettings ++ Seq(
libraryDependencies ++= Seq(
"com.github.fd4s" %% "vulcan" % vulcanVersion,
"io.confluent" % "kafka-avro-serializer" % confluentVersion
)
),
publishSettings,
mimaSettings,
scalaSettings,
testSettings
)
.dependsOn(core)
lazy val docs = project
.in(file("docs"))
.settings(
moduleName := "fs2-kafka-docs",
name := moduleName.value,
dependencySettings,
noPublishSettings,
scalaSettings,
mdocSettings,
buildInfoSettings
)
.dependsOn(core, vulcan)
.enablePlugins(BuildInfoPlugin, DocusaurusPlugin, MdocPlugin, ScalaUnidocPlugin)
lazy val dependencySettings = Seq(
resolvers += "confluent" at "https://packages.confluent.io/maven/",
libraryDependencies ++= Seq(
"io.github.embeddedkafka" %% "embedded-kafka" % embeddedKafkaVersion,
"org.typelevel" %% "discipline-scalatest" % "1.0.1",
"org.typelevel" %% "cats-effect-laws" % catsEffectVersion,
"ch.qos.logback" % "logback-classic" % "1.2.3"
).map(_ % Test),
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"),
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.11.0" cross CrossVersion.full),
pomPostProcess := { (node: xml.Node) =>
new xml.transform.RuleTransformer(new xml.transform.RewriteRule {
def scopedDependency(e: xml.Elem): Boolean =
e.label == "dependency" && e.child.exists(_.label == "scope")
override def transform(node: xml.Node): xml.NodeSeq =
node match {
case e: xml.Elem if scopedDependency(e) => Nil
case _ => Seq(node)
}
}).transform(node).head
}
)
lazy val mdocSettings = Seq(
mdoc := run.in(Compile).evaluated,
scalacOptions --= Seq("-Xfatal-warnings", "-Ywarn-unused"),
crossScalaVersions := Seq(scalaVersion.value),
unidocProjectFilter in (ScalaUnidoc, unidoc) := inProjects(core, vulcan),
target in (ScalaUnidoc, unidoc) := (baseDirectory in LocalRootProject).value / "website" / "static" / "api",
cleanFiles += (target in (ScalaUnidoc, unidoc)).value,
docusaurusCreateSite := docusaurusCreateSite
.dependsOn(unidoc in Compile)
.dependsOn(updateSiteVariables in ThisBuild)
.value,
docusaurusPublishGhpages :=
docusaurusPublishGhpages
.dependsOn(unidoc in Compile)
.dependsOn(updateSiteVariables in ThisBuild)
.value,
// format: off
scalacOptions in (ScalaUnidoc, unidoc) ++= Seq(
"-doc-source-url", s"https://github.com/fd4s/fs2-kafka/tree/v${(latestVersion in ThisBuild).value}€{FILE_PATH}.scala",
"-sourcepath", baseDirectory.in(LocalRootProject).value.getAbsolutePath,
"-doc-title", "FS2 Kafka",
"-doc-version", s"v${(latestVersion in ThisBuild).value}"
)
// format: on
)
lazy val buildInfoSettings = Seq(
buildInfoPackage := "fs2.kafka.build",
buildInfoObject := "info",
buildInfoKeys := Seq[BuildInfoKey](
scalaVersion,
scalacOptions,
sourceDirectory,
latestVersion in ThisBuild,
BuildInfoKey.map(version in ThisBuild) {
case (_, v) => "latestSnapshotVersion" -> v
},
BuildInfoKey.map(moduleName in core) {
case (k, v) => "core" ++ k.capitalize -> v
},
BuildInfoKey.map(crossScalaVersions in core) {
case (k, v) => "core" ++ k.capitalize -> v
},
BuildInfoKey.map(moduleName in vulcan) {
case (k, v) => "vulcan" ++ k.capitalize -> v
},
BuildInfoKey.map(crossScalaVersions in vulcan) {
case (k, v) => "vulcan" ++ k.capitalize -> v
},
organization in LocalRootProject,
crossScalaVersions in core,
BuildInfoKey("fs2Version" -> fs2Version),
BuildInfoKey("kafkaVersion" -> kafkaVersion),
BuildInfoKey("vulcanVersion" -> vulcanVersion),
BuildInfoKey("confluentVersion" -> confluentVersion)
)
)
lazy val metadataSettings = Seq(
organization := "com.github.fd4s"
)
lazy val publishSettings =
metadataSettings ++ Seq(
publishArtifact in Test := false,
pomIncludeRepository := (_ => false),
homepage := Some(url("https://fd4s.github.io/fs2-kafka")),
licenses := List("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.txt")),
startYear := Some(2018),
headerLicense := Some(
de.heikoseeberger.sbtheader.License.ALv2(
s"${startYear.value.get}-${java.time.Year.now}",
"OVO Energy Limited",
HeaderLicenseStyle.SpdxSyntax
)
),
excludeFilter.in(headerSources) := HiddenFileFilter,
developers := List(
Developer(
id = "vlovgr",
name = "Viktor Lövgren",
email = "github@vlovgr.se",
url = url("https://vlovgr.se")
)
)
)
lazy val mimaSettings = Seq(
mimaPreviousArtifacts := {
if (publishArtifact.value) {
Set(organization.value %% moduleName.value % (previousStableVersion in ThisBuild).value.get)
} else Set()
},
mimaBinaryIssueFilters ++= {
import com.typesafe.tools.mima.core._
// format: off
Seq(
ProblemFilters.exclude[Problem]("fs2.kafka.internal.*"),
ProblemFilters.exclude[IncompatibleSignatureProblem]("*")
)
// format: on
}
)
lazy val noPublishSettings =
publishSettings ++ Seq(
skip in publish := true,
publishArtifact := false
)
lazy val scalaSettings = Seq(
scalaVersion := scala213,
crossScalaVersions := Seq(scala212, scala213),
scalacOptions ++= Seq(
"-deprecation",
"-encoding",
"UTF-8",
"-feature",
"-language:higherKinds",
"-language:implicitConversions",
"-unchecked",
"-Xfatal-warnings",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Ywarn-unused",
"-Ypartial-unification"
).filter {
case ("-Yno-adapted-args" | "-Ypartial-unification") if scalaVersion.value.startsWith("2.13") =>
false
case _ => true
},
scalacOptions in (Compile, console) --= Seq("-Xlint", "-Ywarn-unused"),
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value
)
lazy val testSettings = Seq(
logBuffered in Test := false,
parallelExecution in Test := false,
testOptions in Test += Tests.Argument("-oDF")
)
def minorVersion(version: String): String = {
val (major, minor) =
CrossVersion.partialVersion(version).get
s"$major.$minor"
}
val latestVersion = settingKey[String]("Latest stable released version")
latestVersion in ThisBuild := {
val snapshot = (isSnapshot in ThisBuild).value
val stable = (isVersionStable in ThisBuild).value
if (!snapshot && stable) {
(version in ThisBuild).value
} else {
(previousStableVersion in ThisBuild).value.get
}
}
val updateSiteVariables = taskKey[Unit]("Update site variables")
updateSiteVariables in ThisBuild := {
val file =
(baseDirectory in LocalRootProject).value / "website" / "variables.js"
val variables =
Map[String, String](
"organization" -> (organization in LocalRootProject).value,
"coreModuleName" -> (moduleName in core).value,
"latestVersion" -> (latestVersion in ThisBuild).value,
"scalaPublishVersions" -> {
val minorVersions = (crossScalaVersions in core).value.map(minorVersion)
if (minorVersions.size <= 2) minorVersions.mkString(" and ")
else minorVersions.init.mkString(", ") ++ " and " ++ minorVersions.last
}
)
val fileHeader =
"// Generated by sbt. Do not edit directly."
val fileContents =
variables.toList
.sortBy { case (key, _) => key }
.map { case (key, value) => s" $key: '$value'" }
.mkString(s"$fileHeader\nmodule.exports = {\n", ",\n", "\n};\n")
IO.write(file, fileContents)
}
def addCommandsAlias(name: String, values: List[String]) =
addCommandAlias(name, values.mkString(";", ";", ""))
addCommandsAlias(
"validate",
List(
"+clean",
"+coverage",
"+test",
"+coverageReport",
"+mimaReportBinaryIssues",
"+scalafmtCheck",
"scalafmtSbtCheck",
"+headerCheck",
"+doc",
"docs/run"
)
)