-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.sbt
497 lines (443 loc) · 18.7 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
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
import com.jsuereth.sbtpgp.PgpKeys.publishSigned
import com.lightbend.paradox.apidoc.ApidocPlugin.autoImport.apidocRootPackage
val scala213 = "2.13.13"
ThisBuild / scalaVersion := scala213
ThisBuild / organization := "aiven.io"
ThisBuild / organizationName := "Aiven"
ThisBuild / organizationHomepage := Some(url("https://aiven.io/"))
// Remove when Pekko Connectors 1.0.2 is out
ThisBuild / resolvers += Resolver.ApacheMavenSnapshotsRepo
val pekkoVersion = "1.1.0-M0+204-d829637e-SNAPSHOT" // Change to 1.1.0 when its released
val pekkoHttpVersion = "1.0.1"
val pekkoConnectorsKafkaVersion = "1.0.0"
val kafkaClientsVersion = "3.7.0"
val pekkoConnectorsVersion = "1.0.2"
val futilesVersion = "2.0.2"
val quillJdbcMonixVersion = "3.7.2"
val postgresqlJdbcVersion = "42.7.3"
val scalaLoggingVersion = "3.9.5"
val logbackClassicVersion = "1.5.6"
val declineVersion = "2.4.1"
val pureConfigVersion = "0.17.6"
val scalaTestVersion = "3.2.18"
val scalaTestScalaCheckVersion = s"$scalaTestVersion.0"
val pekkoStreamCirceVersion = "1.0.0"
val diffxVersion = "0.9.0"
val testContainersVersion = "0.40.16"
val testContainersJavaVersion = "1.19.8"
val scalaCheckVersion = "1.18.0"
val scalaCheckOpsVersion = "2.10.0"
val enumeratumVersion = "1.7.2"
/** Calculates the scalatest version in a format that is used for `org.scalatestplus` scalacheck artifacts
*
* @see
* https://www.scalatest.org/user_guide/property_based_testing
*/
def scalaTestPlusScalaCheckVersion(version: String) =
version.split('.').take(2).mkString("-")
val scalaTestScalaCheckArtifact = s"scalacheck-${scalaTestPlusScalaCheckVersion(scalaCheckVersion)}"
// See https://github.com/akka/akka-http/pull/3995 and https://github.com/akka/akka-http/pull/3995#issuecomment-1026978593
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % "always"
val flagsFor12 = Seq(
"-Xlint:_",
"-Ywarn-infer-any",
"-Ywarn-adapted-args", // Warn if an argument list is modified to match the receiver
"-Ywarn-inaccessible",
"-Ywarn-infer-any",
"-language:existentials",
"-opt-inline-from:<sources>",
"-opt:l:method"
)
val flagsFor13 = Seq(
"-Xlint:_",
"-Xfatal-warnings",
"-Ywarn-unused",
"-Xlint:adapted-args",
"-Wconf:cat=unused:info",
"-language:existentials",
"-opt-inline-from:<sources>",
"-opt:l:method"
)
val librarySettings = Seq(
crossScalaVersions := List(scala213),
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n == 13 =>
flagsFor13
case Some((2, n)) if n == 12 =>
flagsFor12
}
}
)
val cliSettings = Seq(
publishArtifact := false,
scalacOptions ++= Seq(
"-opt-inline-from:**", // See https://www.lightbend.com/blog/scala-inliner-optimizer
"-opt:l:method"
) ++ flagsFor13,
publish / skip := true,
publishLocal / skip := true,
publishSigned / skip := true,
rpmVendor := "Aiven",
rpmLicense := Some("ASL 2.0")
)
val baseName = "guardian-for-apache-kafka"
lazy val guardian = project
.in(file("."))
.enablePlugins(ScalaUnidocPlugin)
.disablePlugins(SitePlugin)
.aggregate(
core,
coreCli,
coreS3,
coreGCS,
coreBackup,
backupS3,
backupGCS,
cliBackup,
coreCompaction,
compactionS3,
compactionGCS,
cliCompaction,
coreRestore,
restoreS3,
restoreGCS,
cliRestore
)
.settings(
name := s"$baseName-root",
publish / skip := true,
crossScalaVersions := List() // workaround for https://github.com/sbt/sbt/issues/3465
)
lazy val core = project
.in(file("core"))
.settings(
librarySettings,
name := s"$baseName-core",
libraryDependencies ++= Seq(
"org.apache.pekko" %% "pekko-actor" % pekkoVersion,
"org.apache.pekko" %% "pekko-stream" % pekkoVersion,
"org.apache.pekko" %% "pekko-connectors-kafka" % pekkoConnectorsKafkaVersion,
// Ideally we shouldn't be explicitly providing a kafka-clients version and instead getting the version
// transitively from pekko-connectors-kafka however there isn't a nice way to extract a transitive dependency
// for usage in linking to documentation.
"org.apache.kafka" % "kafka-clients" % kafkaClientsVersion,
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingVersion,
"com.github.pureconfig" %% "pureconfig" % pureConfigVersion,
"ch.qos.logback" % "logback-classic" % logbackClassicVersion,
"org.mdedetrich" %% "pekko-stream-circe" % pekkoStreamCirceVersion,
"com.markatta" %% "futiles" % futilesVersion,
"org.apache.pekko" %% "pekko-actor" % pekkoVersion % Test,
"org.apache.pekko" %% "pekko-stream" % pekkoVersion % Test,
"org.scalatest" %% "scalatest" % scalaTestVersion % Test,
"org.scalatestplus" %% scalaTestScalaCheckArtifact % scalaTestScalaCheckVersion % Test,
"org.scalacheck" %% "scalacheck" % scalaCheckVersion % Test,
"com.rallyhealth" %% "scalacheck-ops_1-16" % scalaCheckOpsVersion % Test,
"com.softwaremill.diffx" %% "diffx-scalatest-must" % diffxVersion % Test,
"org.apache.pekko" %% "pekko-stream-testkit" % pekkoVersion % Test,
"org.apache.pekko" %% "pekko-http-testkit" % pekkoHttpVersion % Test,
"com.dimafeng" %% "testcontainers-scala-scalatest" % testContainersVersion % Test,
"com.dimafeng" %% "testcontainers-scala-kafka" % testContainersVersion % Test,
"org.testcontainers" % "kafka" % testContainersJavaVersion % Test
)
)
lazy val coreCli = project
.in(file("core-cli"))
.settings(
publish / skip := true,
publishLocal / skip := true,
publishSigned / skip := true,
scalacOptions ++= Seq(
"-opt-inline-from:**", // See https://www.lightbend.com/blog/scala-inliner-optimizer
"-opt:l:method"
) ++ flagsFor13,
name := s"$baseName-core-cli",
libraryDependencies ++= Seq(
"org.apache.pekko" %% "pekko-actor" % pekkoVersion,
"org.apache.pekko" %% "pekko-stream" % pekkoVersion,
"org.apache.pekko" %% "pekko-slf4j" % pekkoVersion,
"com.monovore" %% "decline" % declineVersion,
"com.beachape" %% "enumeratum" % enumeratumVersion
)
)
.dependsOn(core)
lazy val coreS3 = project
.in(file("core-s3"))
.settings(
librarySettings,
name := s"$baseName-s3",
libraryDependencies ++= Seq(
"org.apache.pekko" %% "pekko-connectors-s3" % pekkoConnectorsVersion,
// Ordinarily this would be in Test scope however if its not then a lower version of pekko-http-xml which has a
// security vulnerability gets resolved in Compile scope
"org.apache.pekko" %% "pekko-http-xml" % pekkoHttpVersion,
"org.scalatest" %% "scalatest" % scalaTestVersion % Test,
"org.scalatestplus" %% scalaTestScalaCheckArtifact % scalaTestScalaCheckVersion % Test,
"com.monovore" %% "decline" % declineVersion % Test
)
)
.dependsOn(core % "compile->compile;test->test")
lazy val coreGCS = project
.in(file("core-gcs"))
.settings(
librarySettings,
name := s"$baseName-gcs",
libraryDependencies ++= Seq(
"org.apache.pekko" %% "pekko-connectors-google-cloud-storage" % pekkoConnectorsVersion,
// Ordinarily this would be in Test scope however if its not then a lower version of pekko-http-spray-json which
// has a security vulnerability gets resolved in Compile scope
"org.apache.pekko" %% "pekko-http-spray-json" % pekkoHttpVersion,
"org.scalatest" %% "scalatest" % scalaTestVersion % Test,
"org.scalatestplus" %% scalaTestScalaCheckArtifact % scalaTestScalaCheckVersion % Test
)
)
.dependsOn(core % "compile->compile;test->test")
lazy val coreBackup = project
.in(file("core-backup"))
.settings(
librarySettings,
name := s"$baseName-core-backup"
)
.dependsOn(core % "compile->compile;test->test")
lazy val backupS3 = project
.in(file("backup-s3"))
.settings(
librarySettings,
Test / fork := true,
name := s"$baseName-backup-s3"
)
.dependsOn(coreS3 % "compile->compile;test->test", coreBackup % "compile->compile;test->test")
lazy val backupGCS = project
.in(file("backup-gcs"))
.settings(
librarySettings,
Test / fork := true,
name := s"$baseName-backup-gcs"
)
.dependsOn(coreGCS % "compile->compile;test->test", coreBackup % "compile->compile;test->test")
lazy val cliBackup = project
.in(file("cli-backup"))
.settings(
cliSettings,
name := s"$baseName-cli-backup",
executableScriptName := "guardian-backup"
)
.dependsOn(coreCli % "compile->compile;test->test",
backupS3 % "compile->compile;test->test",
backupGCS % "compile->compile;test->test"
)
.enablePlugins(JavaAppPackaging)
lazy val coreCompaction = project
.in(file("core-compaction"))
.settings(
librarySettings,
name := s"$baseName-core-compaction",
libraryDependencies ++= Seq(
"org.postgresql" % "postgresql" % postgresqlJdbcVersion
)
)
.dependsOn(core)
lazy val compactionS3 = project
.in(file("compaction-s3"))
.settings(
librarySettings,
name := s"$baseName-compaction-s3"
)
.dependsOn(coreS3, coreCompaction)
lazy val compactionGCS = project
.in(file("compaction-gcs"))
.settings(
librarySettings,
name := s"$baseName-compaction-gcs"
)
.dependsOn(coreGCS, coreCompaction)
lazy val cliCompaction = project
.in(file("cli-compaction"))
.settings(
cliSettings,
name := s"$baseName-cli-compaction",
executableScriptName := "guardian-compaction"
)
.dependsOn(coreCli, compactionS3, compactionGCS)
.enablePlugins(JavaAppPackaging)
lazy val coreRestore = project
.in(file("core-restore"))
.settings(
librarySettings,
name := s"$baseName-core-restore"
)
.dependsOn(core % "compile->compile;test->test")
.dependsOn(coreBackup % "test->test")
lazy val restoreS3 = project
.in(file("restore-s3"))
.settings(
librarySettings,
name := s"$baseName-restore-s3"
)
.dependsOn(coreRestore % "compile->compile;test->test", coreS3 % "compile->compile;test->test")
.dependsOn(backupS3 % "test->compile")
lazy val restoreGCS = project
.in(file("restore-gcs"))
.settings(
librarySettings,
name := s"$baseName-restore-gcs"
)
.dependsOn(coreRestore % "compile->compile;test->test", coreGCS % "compile->compile;test->test")
lazy val cliRestore = project
.in(file("cli-restore"))
.settings(
cliSettings,
name := s"$baseName-cli-restore",
executableScriptName := "guardian-restore"
)
.dependsOn(coreCli % "compile->compile;test->test",
restoreS3 % "compile->compile;test->test",
restoreGCS % "compile->compile;test->test"
)
.enablePlugins(JavaAppPackaging)
def binaryVersion(key: String): String = key.substring(0, key.lastIndexOf('.'))
lazy val docs = project
.enablePlugins(ParadoxPlugin, ParadoxSitePlugin, PreprocessPlugin, GhpagesPlugin)
.settings(
Compile / paradox / name := "Guardian for Apache Kafka",
publish / skip := true,
makeSite := makeSite.dependsOn(LocalRootProject / ScalaUnidoc / doc).value,
previewPath := (Paradox / siteSubdirName).value,
paradoxTheme := Some(builtinParadoxTheme("generic")),
apidocRootPackage := "io.aiven.guardian",
Preprocess / siteSubdirName := s"api/${projectInfoVersion.value}",
Preprocess / sourceDirectory := (LocalRootProject / ScalaUnidoc / unidoc / target).value,
git.remoteRepo := scmInfo.value.get.connection.replace("scm:git:", ""),
paradoxGroups := Map("Language" -> Seq("Scala")),
paradoxProperties ++= Map(
"pekko.version" -> pekkoVersion,
"pekko-http.version" -> pekkoHttpVersion,
"pekko-stream-circe.version" -> pekkoStreamCirceVersion,
"pure-config.version" -> pureConfigVersion,
"decline.version" -> declineVersion,
"scala-logging.version" -> scalaLoggingVersion,
// TODO: Replace current with binaryVersion(pekkoVersion) when pekko is released
"extref.pekko.base_url" -> s"https://pekko.apache.org/api/pekko/current/%s",
"extref.pekko-docs.base_url" -> s"https://pekko.apache.org/docs/pekko/current/%s",
"extref.pekko-stream-circe.base_url" -> s"https://github.com/mdedetrich/pekko-streams-circe",
"extref.pekko-connectors.base_url" -> s"https://pekko.apache.org/api/pekko-connectors/current/%s",
"extref.pekko-connectors-docs.base_url" -> s"https://pekko.apache.org/docs/pekko-connectors/current/%s",
"extref.pekko-connectors-kafka-docs.base_url" -> s"https://pekko.apache.org/docs/pekko-connectors-kafka/current/%s",
"extref.kafka-docs.base_url" -> s"https://kafka.apache.org/${binaryVersion(kafkaClientsVersion).replace(".", "")}/%s",
"extref.pureconfig.base_url" -> s"https://pureconfig.github.io/docs/",
"extref.scalatest.base_url" -> s"https://www.scalatest.org/scaladoc/$scalaTestVersion/org/scalatest/%s",
"github.base_url" -> s"https://github.com/aiven/guardian-for-apache-kafka/tree/${if (isSnapshot.value) "main"
else "v" + version.value}",
"scaladoc.io.aiven.guardian.base_url" -> s"/guardian-for-apache-kafka/${(Preprocess / siteSubdirName).value}/"
),
Compile / paradoxMarkdownToHtml / sourceGenerators += Def.taskDyn {
val targetFile = (Compile / paradox / sourceManaged).value / "license-report.md"
(LocalRootProject / dumpLicenseReportAggregate).map { dir =>
IO.copy(List(dir / s"$baseName-root-licenses.md" -> targetFile)).toList
}
}.taskValue
)
ThisBuild / homepage := Some(url("https://github.com/aiven/guardian-for-apache-kafka"))
ThisBuild / scmInfo := Some(
ScmInfo(url("https://github.com/aiven/guardian-for-apache-kafka"),
"scm:git:[email protected]:aiven/guardian-for-apache-kafka.git"
)
)
ThisBuild / startYear := Some(2021)
ThisBuild / developers := List(
Developer("ahmedsobeh", "Ahmed Sobeh", "[email protected]", url("https://github.com/ahmedsobeh")),
Developer("jlprat", "Josep Prat", "[email protected]", url("https://github.com/jlprat")),
Developer("mdedetrich", "Matthew de Detrich", "[email protected]", url("https://github.com/mdedetrich")),
Developer("reta", "Andriy Redko", "[email protected]", url("https://github.com/reta")),
Developer("RyanSkraba", "Ryan Skraba", "[email protected]", url("https://github.com/RyanSkraba"))
)
maintainer := "[email protected]"
ThisBuild / licenses += ("Apache-2.0", url("https://opensource.org/licenses/Apache-2.0"))
// This is currently causing problems, see https://github.com/djspiewak/sbt-github-actions/issues/74
ThisBuild / githubWorkflowUseSbtThinClient := false
ThisBuild / githubWorkflowTargetBranches := Seq("main")
// Once we have branches per version, add the pattern here, see
// https://github.com/djspiewak/sbt-github-actions#integration-with-sbt-ci-release
ThisBuild / githubWorkflowPublishTargetBranches := Seq(RefPredicate.Equals(Ref.Branch("main")))
ThisBuild / githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("docs/ghpagesPushSite")))
ThisBuild / githubWorkflowPublishPreamble := Seq(
// Taken from https://github.com/actions/checkout/issues/13#issue-481453396
WorkflowStep.Run(
commands = List(
"git config --global user.name \"$(git --no-pager log --format=format:'%an' -n 1)\"",
"git config --global user.email \"$(git --no-pager log --format=format:'%ae' -n 1)\""
)
),
WorkflowStep.Use(
ref = UseRef.Public("webfactory", "ssh-agent", "v0.5.4"),
params = Map(
"ssh-private-key" -> "${{ secrets.GH_PAGES_SSH_PRIVATE_KEY }}"
)
)
)
ThisBuild / githubWorkflowBuildPreamble := Seq(
WorkflowStep.Sbt(List("scalafixAll --check"), name = Some("Linter: Scalafix checks"))
)
ThisBuild / scalafixScalaBinaryVersion := scalaBinaryVersion.value
ThisBuild / semanticdbEnabled := true
// See https://scalacenter.github.io/scalafix/docs/users/installation.html#sbt
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision
ThisBuild / githubWorkflowJavaVersions := List(JavaSpec.temurin("11"))
ThisBuild / githubWorkflowBuildPreamble ++= Seq(
WorkflowStep.Use(
UseRef.Public("aws-actions", "configure-aws-credentials", "v2"),
name = Some("Configure AWS credentials"),
params = Map(
"role-to-assume" -> "arn:aws:iam::310017459104:role/aiven-guardian-github-action",
"aws-region" -> "us-west-2",
"role-duration-seconds" -> "7200" // 4 hours
)
)
)
ThisBuild / githubWorkflowPermissions := Some(
Permissions.Specify(
Map(
PermissionScope.IdToken -> PermissionValue.Write
)
)
)
ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(
List("clean", "coverage", "test"),
name = Some("Build project"),
env = Map(
"PEKKO_CONNECTORS_S3_REGION_PROVIDER" -> "default",
"PEKKO_CONNECTORS_S3_AWS_CREDENTIALS_PROVIDER" -> "default"
)
),
WorkflowStep.Sbt(List("docs/makeSite"), name = Some("Compile docs"))
)
ThisBuild / githubWorkflowBuildPostamble ++= Seq(
// See https://github.com/scoverage/sbt-coveralls#github-actions-integration
WorkflowStep.Sbt(
List("coverageReport", "coverageAggregate", "coveralls"),
name = Some("Upload coverage data to Coveralls"),
env = Map(
"COVERALLS_REPO_TOKEN" -> "${{ secrets.GITHUB_TOKEN }}",
"COVERALLS_FLAG_NAME" -> "Scala ${{ matrix.scala }}"
)
)
)
dependencyCheckOutputDirectory := Some(baseDirectory.value / "dependency-check")
dependencyCheckSuppressionFile := Some(baseDirectory.value / "dependency-check" / "suppression.xml")
import ReleaseTransformations._
releaseCrossBuild := true
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining("+publishSigned"),
releaseStepCommand("sonatypeReleaseAll"),
setNextVersion,
commitNextVersion,
pushChanges
)