forked from akka/alpakka-kafka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
357 lines (344 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
enablePlugins(AutomateHeaderPlugin)
name := "akka-stream-kafka"
val Scala213 = "2.13.0"
val akkaVersion = "2.5.23"
val kafkaVersion = "2.1.1"
val kafkaVersionForDocs = "21"
val scalatestVersion = "3.0.8"
val testcontainersVersion = "1.11.2"
val slf4jVersion = "1.7.26"
val confluentAvroSerializerVersion = "5.0.1"
val kafkaScale = settingKey[Int]("Number of kafka docker containers")
resolvers in ThisBuild ++= Seq(
// for Embedded Kafka
Resolver.bintrayRepo("manub", "maven"),
// for Jupiter interface (JUnit 5)
Resolver.jcenterRepo
)
val commonSettings = Seq(
organization := "com.typesafe.akka",
organizationName := "Lightbend Inc.",
organizationHomepage := Some(url("https://www.lightbend.com/")),
homepage := Some(url("https://doc.akka.io/docs/alpakka-kafka/current/")),
scmInfo := Some(ScmInfo(url("https://github.com/akka/alpakka-kafka"), "[email protected]:akka/alpakka-kafka.git")),
developers += Developer("contributors",
"Contributors",
"https://gitter.im/akka/dev",
url("https://github.com/akka/alpakka-kafka/graphs/contributors")),
startYear := Some(2014),
licenses := Seq("Apache-2.0" -> url("http://opensource.org/licenses/Apache-2.0")),
description := "Alpakka is a Reactive Enterprise Integration library for Java and Scala, based on Reactive Streams and Akka.",
crossScalaVersions := Seq("2.12.8", "2.11.12", Scala213),
scalaVersion := "2.12.8",
crossVersion := CrossVersion.binary,
javacOptions ++= Seq(
"-Xlint:deprecation"
),
scalacOptions ++= Seq(
"-deprecation",
"-encoding",
"UTF-8", // yes, this is 2 args
"-feature",
"-unchecked",
"-Xlint",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen"
) ++ {
if (scalaBinaryVersion.value == "2.13") Seq.empty
else Seq("-Yno-adapted-args", "-Xfuture")
},
scalacOptions in (Compile, doc) := scalacOptions.value ++ Seq(
"-doc-title",
"Alpakka Kafka",
"-doc-version",
version.value,
"-sourcepath",
(baseDirectory in ThisBuild).value.toString,
"-doc-source-url", {
val branch = if (isSnapshot.value) "master" else s"v${version.value}"
s"https://github.com/akka/alpakka-kafka/tree/${branch}€{FILE_PATH}.scala#L1"
},
"-skip-packages",
"akka.pattern" // for some reason Scaladoc creates this
),
// show full stack traces and test case durations
testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oDF"),
// https://github.com/maichler/sbt-jupiter-interface#framework-options
// -a Show stack traces and exception class name for AssertionErrors.
// -v Log "test run started" / "test started" / "test run finished" events on log level "info" instead of "debug".
// -q Suppress stdout for successful tests.
// -s Try to decode Scala names in stack traces and test names.
testOptions += Tests.Argument(jupiterTestFramework, "-a", "-v", "-q", "-s"),
scalafmtOnCompile := true,
headerLicense := Some(
HeaderLicense.Custom(
"""|Copyright (C) 2014 - 2016 Softwaremill <http://softwaremill.com>
|Copyright (C) 2016 - 2019 Lightbend Inc. <http://www.lightbend.com>
|""".stripMargin
)
),
bintrayOrganization := Some("akka"),
bintrayPackage := "alpakka-kafka",
bintrayRepository := (if (isSnapshot.value) "snapshots" else "maven"),
projectInfoVersion := (if (isSnapshot.value) "snapshot" else version.value)
)
lazy val `alpakka-kafka` =
project
.in(file("."))
.enablePlugins(ScalaUnidocPlugin)
.disablePlugins(SitePlugin)
.settings(commonSettings)
.settings(
skip in publish := true,
crossScalaVersions := Nil,
dockerComposeIgnore := true,
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(core, testkit),
onLoadMessage :=
"""
|** Welcome to the Alpakka Kafka connector! **
|
|The build has three main modules:
| core - the Kafka connector sources
| tests - tests, Docker based integration tests, code for the documentation
| testkit - framework for testing the connector
|
|Other modules:
| docs - the sources for generating https://doc.akka.io/docs/alpakka-kafka/current
| benchmarks - compare direct Kafka API usage with Alpakka Kafka
|
|Useful sbt tasks:
|
| docs/previewSite
| builds Paradox and Scaladoc documentation, starts a webserver and
| opens a new browser window
|
| test
| runs all the tests
|
| tests/dockerComposeTest it:test
| run integration test backed by Docker containers
|
| benchmarks/dockerComposeTest it:testOnly *.AlpakkaKafkaPlainConsumer
| run a single benchmark backed by Docker containers
""".stripMargin
)
.aggregate(core, testkit, tests, benchmarks, docs)
lazy val core = project
.enablePlugins(AutomateHeaderPlugin)
.disablePlugins(SitePlugin)
.settings(commonSettings)
.settings(
name := "akka-stream-kafka",
AutomaticModuleName.settings("akka.stream.alpakka.kafka"),
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
"org.apache.kafka" % "kafka-clients" % kafkaVersion
),
mimaPreviousArtifacts := Set(
organization.value %% name.value % previousStableVersion.value
.getOrElse(throw new Error("Unable to determine previous version"))
)
)
lazy val testkit = project
.dependsOn(core)
.enablePlugins(AutomateHeaderPlugin)
.disablePlugins(MimaPlugin, SitePlugin)
.settings(commonSettings)
.settings(
name := "akka-stream-kafka-testkit",
AutomaticModuleName.settings("akka.stream.alpakka.kafka.testkit"),
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion,
"org.testcontainers" % "kafka" % testcontainersVersion % Provided,
"org.apache.commons" % "commons-compress" % "1.18", // embedded Kafka pulls in Avro which pulls in commons-compress 1.8.1
"org.scalatest" %% "scalatest" % scalatestVersion % Provided,
"junit" % "junit" % "4.12" % Provided,
"org.junit.jupiter" % "junit-jupiter-api" % JupiterKeys.junitJupiterVersion.value % Provided
) ++ {
if (scalaBinaryVersion.value == "2.13") Seq()
else
Seq(
"org.apache.kafka" %% "kafka" % kafkaVersion exclude ("org.slf4j", "slf4j-log4j12"),
"io.github.embeddedkafka" %% "embedded-kafka" % kafkaVersion exclude ("log4j", "log4j")
)
},
Compile / unmanagedSources / excludeFilter := {
if (scalaBinaryVersion.value == "2.13") {
HiddenFileFilter ||
"EmbeddedKafkaLike.scala" ||
"EmbeddedKafkaTest.java" ||
"EmbeddedKafkaJunit4Test.java"
} else (Test / unmanagedSources / excludeFilter).value
},
mimaPreviousArtifacts := Set(
organization.value %% name.value % previousStableVersion.value
.getOrElse(throw new Error("Unable to determine previous version"))
)
)
lazy val tests = project
.dependsOn(core, testkit)
.enablePlugins(AutomateHeaderPlugin, DockerCompose, BuildInfoPlugin)
.disablePlugins(MimaPlugin, SitePlugin)
.configs(IntegrationTest)
.settings(commonSettings)
.settings(Defaults.itSettings)
.settings(automateHeaderSettings(IntegrationTest))
.settings(
name := "akka-stream-kafka-tests",
libraryDependencies ++= Seq(
"io.confluent" % "kafka-avro-serializer" % confluentAvroSerializerVersion % Test,
// See https://github.com/sbt/sbt/issues/3618#issuecomment-448951808
"javax.ws.rs" % "javax.ws.rs-api" % "2.1.1" artifacts Artifact("javax.ws.rs-api", "jar", "jar"),
"org.testcontainers" % "kafka" % testcontainersVersion % Test,
"org.apache.commons" % "commons-compress" % "1.18", // embedded Kafka pulls in Avro, which pulls in commons-compress 1.8.1, see testing.md
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"io.spray" %% "spray-json" % "1.3.5" % Test,
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.8" % Test, // ApacheV2
"org.junit.vintage" % "junit-vintage-engine" % JupiterKeys.junitVintageVersion.value % Test,
// See http://hamcrest.org/JavaHamcrest/distributables#upgrading-from-hamcrest-1x
"org.hamcrest" % "hamcrest-library" % "2.1" % Test,
"org.hamcrest" % "hamcrest" % "2.1" % Test,
"net.aichler" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test,
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion % Test,
"ch.qos.logback" % "logback-classic" % "1.2.3" % Test,
"org.slf4j" % "log4j-over-slf4j" % slf4jVersion % Test,
// Schema registry uses Glassfish which uses java.util.logging
"org.slf4j" % "jul-to-slf4j" % slf4jVersion % Test,
"org.mockito" % "mockito-core" % "2.24.5" % Test
) ++ {
if (scalaBinaryVersion.value == "2.13") Seq()
else
Seq(
"io.github.embeddedkafka" %% "embedded-kafka-schema-registry" % "5.2.1" % Test exclude ("log4j", "log4j") exclude ("org.slf4j", "slf4j-log4j12")
)
} ++
Seq( // integration test dependencies
"com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion % IntegrationTest,
"org.scalatest" %% "scalatest" % scalatestVersion % IntegrationTest,
"com.spotify" % "docker-client" % "8.11.7" % IntegrationTest,
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion % IntegrationTest,
"ch.qos.logback" % "logback-classic" % "1.2.3" % IntegrationTest,
"org.slf4j" % "log4j-over-slf4j" % slf4jVersion % IntegrationTest
),
resolvers += "Confluent Maven Repo" at "https://packages.confluent.io/maven/",
publish / skip := true,
whitesourceIgnore := true,
Test / fork := true,
Test / parallelExecution := false,
IntegrationTest / parallelExecution := false,
Test / unmanagedSources / excludeFilter := {
if (scalaBinaryVersion.value == "2.13") {
HiddenFileFilter ||
"RetentionPeriodSpec.scala" ||
"IntegrationSpec.scala" ||
"MultiConsumerSpec.scala" ||
"ReconnectSpec.scala" ||
"EmbeddedKafkaSampleSpec.scala" ||
"TransactionsSpec.scala" ||
"SerializationSpec.scala" ||
"PartitionExamples.scala" ||
"TransactionsExample.scala" ||
"EmbeddedKafkaWithSchemaRegistryTest.java" ||
"AssignmentTest.java" ||
"ProducerExampleTest.java" ||
"SerializationTest.java" ||
"TransactionsExampleTest.java"
} else (Test / unmanagedSources / excludeFilter).value
},
kafkaScale := 3,
buildInfoPackage := "akka.kafka",
buildInfoKeys := Seq[BuildInfoKey](kafkaScale),
dockerComposeTestLogging := true,
dockerComposeFilePath := (baseDirectory.value / ".." / "docker-compose.yml").getAbsolutePath,
dockerComposeTestCommandOptions := {
import com.github.ehsanyou.sbt.docker.compose.commands.test._
DockerComposeTestCmd(DockerComposeTest.ItTest)
.withEnvVar("KAFKA_SCALE", kafkaScale.value.toString)
}
)
commands += Command.command("dockerComposeTestAll") { state ⇒
val extracted = Project.extract(state)
val (_, allTests) = extracted.runTask(tests / IntegrationTest / definedTestNames, state)
allTests.map(test => s"tests/dockerComposeTest it:testOnly $test").foldRight(state)(_ :: _)
}
lazy val docs = project
.enablePlugins(AkkaParadoxPlugin, ParadoxSitePlugin, PreprocessPlugin, PublishRsyncPlugin)
.disablePlugins(BintrayPlugin, MimaPlugin)
.settings(commonSettings)
.settings(
name := "Alpakka Kafka",
publish / skip := true,
whitesourceIgnore := true,
makeSite := makeSite.dependsOn(LocalRootProject / ScalaUnidoc / doc).value,
previewPath := (Paradox / siteSubdirName).value,
Preprocess / siteSubdirName := s"api/alpakka-kafka/${projectInfoVersion.value}",
Preprocess / sourceDirectory := (LocalRootProject / ScalaUnidoc / unidoc / target).value,
Preprocess / preprocessRules := Seq(
("\\.java\\.scala".r, _ => ".java")
),
Paradox / siteSubdirName := s"docs/alpakka-kafka/${projectInfoVersion.value}",
paradoxGroups := Map("Language" -> Seq("Java", "Scala")),
paradoxProperties ++= Map(
"akka.version" -> akkaVersion,
"kafka.version" -> kafkaVersion,
"confluent.version" -> confluentAvroSerializerVersion,
"scalatest.version" -> scalatestVersion,
"testcontainers.version" -> testcontainersVersion,
"extref.akka-docs.base_url" -> s"https://doc.akka.io/docs/akka/$akkaVersion/%s",
"extref.kafka-docs.base_url" -> s"https://kafka.apache.org/$kafkaVersionForDocs/documentation/%s",
"extref.java-docs.base_url" -> "https://docs.oracle.com/en/java/javase/11/%s",
"scaladoc.scala.base_url" -> s"https://www.scala-lang.org/api/current/",
"scaladoc.akka.base_url" -> s"https://doc.akka.io/api/akka/$akkaVersion",
"scaladoc.akka.kafka.base_url" -> s"/${(Preprocess / siteSubdirName).value}/",
"scaladoc.com.typesafe.config.base_url" -> s"https://lightbend.github.io/config/latest/api/",
"javadoc.org.apache.kafka.base_url" -> s"https://kafka.apache.org/$kafkaVersionForDocs/javadoc/"
),
resolvers += Resolver.jcenterRepo,
publishRsyncArtifact := makeSite.value -> "www/",
publishRsyncHost := "[email protected]"
)
lazy val benchmarks = project
.dependsOn(core, testkit)
.enablePlugins(AutomateHeaderPlugin, DockerCompose, BuildInfoPlugin)
.enablePlugins(DockerPlugin)
.disablePlugins(SitePlugin)
.configs(IntegrationTest)
.settings(commonSettings)
.settings(Defaults.itSettings)
.settings(automateHeaderSettings(IntegrationTest))
.settings(
crossScalaVersions -= Scala213,
name := "akka-stream-kafka-benchmarks",
skip in publish := true,
whitesourceIgnore := true,
IntegrationTest / parallelExecution := false,
libraryDependencies ++= Seq(
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.0",
"io.dropwizard.metrics" % "metrics-core" % "3.2.6",
"ch.qos.logback" % "logback-classic" % "1.2.3",
"org.slf4j" % "log4j-over-slf4j" % slf4jVersion,
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion % "it",
"com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion % "it",
"org.scalatest" %% "scalatest" % scalatestVersion % "it"
),
kafkaScale := 1,
buildInfoPackage := "akka.kafka.benchmarks",
buildInfoKeys := Seq[BuildInfoKey](kafkaScale),
dockerComposeTestLogging := false,
dockerComposeFilePath := (baseDirectory.value / ".." / "docker-compose.yml").getAbsolutePath,
dockerComposeTestCommandOptions := {
import com.github.ehsanyou.sbt.docker.compose.commands.test._
DockerComposeTestCmd(DockerComposeTest.ItTest)
.withEnvVar("KAFKA_SCALE", kafkaScale.value.toString)
},
dockerfile in docker := {
val artifact: File = assembly.value
val artifactTargetPath = s"/app/${artifact.name}"
new Dockerfile {
from("netflixoss/java:8")
add(artifact, artifactTargetPath)
entryPoint("java", "-jar", artifactTargetPath)
expose(8080)
}
}
)