forked from TouK/nussknacker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
1312 lines (1201 loc) · 55.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
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import com.typesafe.sbt.packager.SettingsHelper
import com.typesafe.sbt.packager.docker.DockerPlugin.autoImport.dockerUsername
import pl.project13.scala.sbt.JmhPlugin
import pl.project13.scala.sbt.JmhPlugin._
import sbt.Keys._
import sbt.{Def, _}
import sbtassembly.AssemblyPlugin.autoImport.assembly
import sbtassembly.MergeStrategy
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._
import scala.language.postfixOps
import scala.util.Try
import scala.xml.Elem
import scala.xml.transform.{RewriteRule, RuleTransformer}
// Warning: Flink doesn't work correctly with 2.12.11
// Warning: 2.12.13 + crossVersion break sbt-scoverage: https://github.com/scoverage/sbt-scoverage/issues/319
val scala212 = "2.12.10"
lazy val supportedScalaVersions = List(scala212)
// Silencer must be compatible with exact scala version - see compatibility matrix: https://search.maven.org/search?q=silencer-plugin
// Silencer 1.7.x require Scala 2.12.11 (see warning above)
// Silencer (and all '@silent' annotations) can be removed after we can upgrade to 2.12.13...
// https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html
val silencerV_2_12 = "1.6.0"
val silencerV = "1.7.0"
//TODO: replace configuration by system properties with configuration via environment after removing travis scripts
//then we can change names to snake case, for "normal" env variables
def propOrEnv(name: String, default: String): String = propOrEnv(name).getOrElse(default)
def propOrEnv(name: String): Option[String] = Option(System.getProperty(name)).orElse(sys.env.get(name))
//by default we include flink and scala, we want to be able to disable this behaviour for performance reasons
val includeFlinkAndScala = propOrEnv("includeFlinkAndScala", "true").toBoolean
val flinkScope = if (includeFlinkAndScala) "compile" else "provided"
val nexusUrlFromProps = propOrEnv("nexusUrl")
//TODO: this is pretty clunky, but works so far for our case...
val nexusHostFromProps = nexusUrlFromProps.map(_.replaceAll("http[s]?://", "").replaceAll("[:/].*", ""))
//Docker release configuration
val dockerTagName = propOrEnv("dockerTagName")
val dockerPort = propOrEnv("dockerPort", "8080").toInt
val dockerUserName = Option(propOrEnv("dockerUserName", "touk"))
val dockerPackageName = propOrEnv("dockerPackageName", "nussknacker")
val dockerUpLatestFromProp = propOrEnv("dockerUpLatest").flatMap(p => Try(p.toBoolean).toOption)
val addDevModel = propOrEnv("addDevModel", "false").toBoolean
val requestResponseManagementPort = propOrEnv("requestResponseManagementPort", "8070").toInt
val requestResponseProcessesPort = propOrEnv("requestResponseProcessesPort", "8080").toInt
val requestResponseDockerPackageName = propOrEnv("requestResponseDockerPackageName", "nussknacker-request-response-app")
val liteEngineKafkaRuntimeDockerPackageName = propOrEnv("liteEngineKafkaRuntimeDockerPackageName", "nussknacker-lite-kafka-runtime")
// `publishArtifact := false` should be enough to keep sbt from publishing root module,
// unfortunately it does not work, so we resort to hack by publishing root module to Resolver.defaultLocal
//publishArtifact := false
publishTo := Some(Resolver.defaultLocal)
crossScalaVersions := Nil
ThisBuild / isSnapshot := version(_ contains "-SNAPSHOT").value
lazy val publishSettings = Seq(
publishMavenStyle := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
publishTo := {
nexusUrlFromProps.map { url =>
(if (isSnapshot.value) "snapshots" else "releases") at url
}.orElse {
val defaultNexusUrl = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at defaultNexusUrl + "content/repositories/snapshots")
else
sonatypePublishToBundle.value
}
},
Test / publishArtifact := false,
//We don't put scm information here, it will be added by release plugin and if scm provided here is different than the one from scm
//we'll end up with two scm sections and invalid pom...
pomExtra in Global := {
<developers>
<developer>
<id>TouK</id>
<name>TouK</name>
<url>https://touk.pl</url>
</developer>
</developers>
},
organization := "pl.touk.nussknacker",
homepage := Some(url(s"https://github.com/touk/nussknacker")),
credentials := nexusHostFromProps.map(host => Credentials("Sonatype Nexus Repository Manager",
host, propOrEnv("nexusUser", "touk"), propOrEnv("nexusPassword", null))
// otherwise ~/.sbt/1.0/sonatype.sbt will be used
).toSeq
)
def modelMergeStrategy: String => MergeStrategy = {
case PathList(ps@_*) if ps.last == "module-info.class" => MergeStrategy.discard //TODO: we don't handle JDK9 modules well
case PathList(ps@_*) if ps.last == "NumberUtils.class" => MergeStrategy.first //TODO: shade Spring EL?
case PathList("org", "apache", "commons", "logging", _ @ _*) => MergeStrategy.first //TODO: shade Spring EL?
case PathList(ps@_*) if ps.last == "io.netty.versions.properties" => MergeStrategy.first //Netty has buildTime here, which is different for different modules :/
case x => MergeStrategy.defaultMergeStrategy(x)
}
def uiMergeStrategy: String => MergeStrategy = {
case PathList(ps@_*) if ps.last == "module-info.class" => MergeStrategy.discard
case PathList(ps@_*) if ps.last == "NumberUtils.class" => MergeStrategy.first //TODO: shade Spring EL?
case PathList("org", "apache", "commons", "logging", _ @ _*) => MergeStrategy.first //TODO: shade Spring EL?
case PathList(ps@_*) if ps.last == "io.netty.versions.properties" => MergeStrategy.first //Netty has buildTime here, which is different for different modules :/
case PathList("com", "sun", "el", _ @ _*) => MergeStrategy.first //Some legacy batik stuff
case PathList("org", "w3c", "dom", "events", _ @ _*) => MergeStrategy.first //Some legacy batik stuff
case x => MergeStrategy.defaultMergeStrategy(x)
}
def requestResponseMergeStrategy: String => MergeStrategy = {
case PathList(ps@_*) if ps.last == "NumberUtils.class" => MergeStrategy.first //TODO: shade Spring EL?
case PathList("org", "apache", "commons", "logging", _ @ _*) => MergeStrategy.first //TODO: shade Spring EL?
case PathList(ps@_*) if ps.last == "io.netty.versions.properties" => MergeStrategy.first //Netty has buildTime here, which is different for different modules :/
case x => MergeStrategy.defaultMergeStrategy(x)
}
lazy val SlowTests = config("slow") extend Test
val scalaTestReports = Tests.Argument(TestFrameworks.ScalaTest, "-u", "target/surefire-reports", "-oFGD")
val slowTestsSettings =
inConfig(SlowTests)(Defaults.testTasks) ++ Seq(
SlowTests / testOptions := Seq(
Tests.Argument(TestFrameworks.ScalaTest, "-n", "org.scalatest.tags.Slow"),
scalaTestReports
)
)
val ignoreSlowTests = Tests.Argument(TestFrameworks.ScalaTest, "-l", "org.scalatest.tags.Slow")
def forScalaVersion[T](version: String, default: T, specific: ((Int, Int), T)*): T = {
CrossVersion.partialVersion(version).flatMap { case (k, v) =>
specific.toMap.get(k.toInt, v.toInt)
}.getOrElse(default)
}
lazy val commonSettings =
publishSettings ++
Seq(
assembly / test := {},
licenses += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html")),
crossScalaVersions := supportedScalaVersions,
scalaVersion := scala212,
resolvers ++= Seq(
"confluent" at "https://packages.confluent.io/maven"
),
Test / testOptions ++= Seq(scalaTestReports, ignoreSlowTests),
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full),
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.13.2" cross CrossVersion.full),
// We can't use addCompilerPlugin because it not support usage of scalaVersion.value
libraryDependencies += compilerPlugin("com.github.ghik" % "silencer-plugin" % forScalaVersion(scalaVersion.value,
silencerV, (2, 12) -> silencerV_2_12) cross CrossVersion.full),
scalacOptions := Seq(
"-unchecked",
"-deprecation",
"-encoding", "utf8",
"-Xfatal-warnings",
"-feature",
"-language:postfixOps",
"-language:existentials",
"-Ypartial-unification",
//Scala 2.12 does not support target > 8
"-target:jvm-1.8",
"-release",
"11"
),
javacOptions := Seq(
"-Xlint:deprecation",
"-Xlint:unchecked",
// Using --release flag (available only on jdk >= 9) instead of -source -target to avoid usage of api from newer java version
"--release",
"8",
//we use it e.g. to provide consistent behaviour wrt extracting parameter names from scala and java
"-parameters"
),
coverageMinimum := 60,
coverageFailOnMinimum := false,
//problem with scaladoc of api: https://github.com/scala/bug/issues/10134
Compile /doc / scalacOptions -= "-Xfatal-warnings",
libraryDependencies ++= Seq(
"com.github.ghik" % "silencer-lib" % (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => silencerV_2_12
case _ => silencerV
}) % Provided cross CrossVersion.full,
"org.scala-lang.modules" %% "scala-collection-compat" % scalaCollectionsCompatV
),
//here we add dependencies that we want to have fixed across all modules
dependencyOverrides ++= Seq(
//currently Flink (1.11 -> https://github.com/apache/flink/blob/master/pom.xml#L128) uses 1.8.2 Avro version
"org.apache.avro" % "avro" % avroV,
"com.typesafe" % "config" % configV,
//we stick to version in Flink to avoid nasty bugs in process runtime...
//NOTE: xmlgraphics used in UI comes with v. old version...
"commons-io" % "commons-io" % commonsIOV,
//we stick to version in Flink to avoid nasty bugs in process runtime...
//NOTE: commons-text (in api) uses 3.9...
"org.apache.commons" % "commons-lang3" % commonsLangV,
"io.circe" %% "circe-core" % circeV,
"io.circe" %% "circe-parser" % circeV,
// Force akka-http and akka-stream versions to avoid bumping by akka-http-circe.
"com.typesafe.akka" %% "akka-http" % akkaHttpV,
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpV,
"com.typesafe.akka" %% "akka-stream" % akkaV,
"com.typesafe.akka" %% "akka-testkit" % akkaV,
//Our main kafka dependencies are Confluent (for avro) and Flink (Kafka connector)
"org.apache.kafka" % "kafka-clients" % kafkaV,
"org.apache.kafka" %% "kafka" % kafkaV,
"io.netty" % "netty-handler" % nettyV,
"io.netty" % "netty-codec" % nettyV,
"io.netty" % "netty-transport-native-epoll" % nettyV,
// Jackson is used by openapi and jwks-rsa
"com.fasterxml.jackson.core" % "jackson-annotations" % jacksonV,
"com.fasterxml.jackson.core" % "jackson-core" % jacksonV,
"com.fasterxml.jackson.core" % "jackson-databind" % jacksonV,
)
)
val akkaV = "2.5.21" //same version as in Flink
val flinkV = "1.14.0"
val avroV = "1.9.2" // for java time logical types conversions purpose
//we should use max(version used by confluent, version used by flink), https://docs.confluent.io/platform/current/installation/versions-interoperability.html - confluent version reference
//however, we stick to 2.4.1, as it's last version supported by scala 2.11 (we use kafka server in tests...)
val kafkaV = "2.4.1"
val kafkaServerV = "2.4.1"
val springV = "5.1.19.RELEASE"
val scalaTestV = "3.0.8"
val scalaCheckV = "1.14.0"
val logbackV = "1.1.3"
val circeV = "0.14.1"
val jwtCirceV = "9.0.1"
val jacksonV = "2.11.3"
val catsV = "2.6.1"
val scalaParsersV = "1.0.4"
val everitSchemaV = "1.13.0"
val slf4jV = "1.7.30"
val scalaLoggingV = "3.9.2"
val scalaCompatV = "0.9.1"
val ficusV = "1.4.7"
val configV = "1.4.1"
val commonsLangV = "3.3.2"
val commonsTextV = "1.8"
val commonsIOV = "2.4"
//we want to use 5.x for lite metrics to have tags, however dropwizard development kind of freezed. Maybe we should consider micrometer?
//In Flink metrics we use bundled dropwizard metrics v. 3.x
val dropWizardV = "5.0.0-rc3"
val scalaCollectionsCompatV = "2.3.2"
val testcontainersScalaV = "0.39.3"
val nettyV = "4.1.48.Final"
val akkaHttpV = "10.1.8"
val akkaHttpCirceV = "1.28.0"
val slickV = "3.3.3"
val hsqldbV = "2.5.1"
val postgresV = "42.2.19"
val flywayV = "6.3.3"
val confluentV = "5.5.4"
val jbcryptV = "0.4"
val cronParserV = "9.1.3"
val javaxValidationApiV = "2.0.1.Final"
val caffeineCacheV = "2.8.8"
val sttpV = "2.2.9"
lazy val commonDockerSettings = {
Seq(
//we use openjdk:11-jdk because openjdk:11-jdk-slim lacks /usr/local/openjdk-11/lib/libfontmanager.so file necessary during pdf export
dockerBaseImage := "openjdk:11-jdk",
dockerUsername := dockerUserName,
dockerUpdateLatest := dockerUpLatestFromProp.getOrElse(!isSnapshot.value),
dockerAliases := {
//https://docs.docker.com/engine/reference/commandline/tag/#extended-description
def sanitize(str: String) = str.replaceAll("[^a-zA-Z0-9._-]", "_")
val alias = dockerAlias.value
val updateLatest = if (dockerUpdateLatest.value) Some("latest") else None
val dockerVersion = Some(version.value)
//TODO: handle it more nicely, checkout actions in CI are not checking out actual branch
//other option would be to reset source branch to checkout out commit
val currentBranch = sys.env.getOrElse("GIT_SOURCE_BRANCH", git.gitCurrentBranch.value)
val latestBranch = Some(currentBranch + "-latest")
List(dockerVersion, updateLatest, latestBranch, dockerTagName)
.flatten
.map(tag => alias.withTag(Some(sanitize(tag))))
.distinct
}
)
}
lazy val distDockerSettings = {
val nussknackerDir = "/opt/nussknacker"
commonDockerSettings ++ Seq(
dockerEntrypoint := Seq(s"$nussknackerDir/bin/nussknacker-entrypoint.sh"),
dockerExposedPorts := Seq(dockerPort),
dockerEnvVars := Map(
"HTTP_PORT" -> dockerPort.toString
),
packageName := dockerPackageName,
dockerLabels := Map(
"version" -> version.value,
"scala" -> scalaVersion.value,
"flink" -> flinkV
),
dockerExposedVolumes := Seq(s"$nussknackerDir/storage", s"$nussknackerDir/data"),
Docker / defaultLinuxInstallLocation := nussknackerDir
)
}
val publishAssemblySettings = List(
Compile /assembly / artifact := {
val art = (Compile / assembly / artifact).value
art.withClassifier(Some("assembly"))
}, addArtifact(Compile /assembly / artifact, assembly)
)
def assemblySettings(assemblyName: String, includeScala: Boolean): List[Def.SettingsDefinition] = List(
assembly / assemblyJarName := assemblyName,
assembly / assemblyOption := (assembly / assemblyOption).value.copy(includeScala = includeScala, level = Level.Info),
assembly / assemblyMergeStrategy := modelMergeStrategy,
assembly / test := {}
)
def assemblyNoScala(assemblyName: String): List[Def.SettingsDefinition]
= assemblySettings(assemblyName, includeScala = false)
lazy val dist = {
val module = sbt.Project("dist", file("nussknacker-dist"))
.settings(commonSettings)
.enablePlugins(SbtNativePackager, JavaServerAppPackaging)
.settings(
Universal / packageName := ("nussknacker" + "-" + version.value),
Compile / Keys.compile := (Compile / Keys.compile).dependsOn(
generic / Compile / assembly,
flinkDeploymentManager / Compile / assembly,
requestResponseRuntime / Compile / assembly,
openapiComponents / Compile / assembly,
sqlComponents / Compile / assembly,
flinkBaseComponents / Compile / assembly,
flinkKafkaComponents / Compile / assembly,
liteBaseComponents / Compile / assembly,
liteEmbeddedDeploymentManager / Compile /assembly,
liteKafkaComponents / Compile / assembly
).value,
Universal / mappings ++= Seq(
(generic / crossTarget).value / "genericModel.jar" -> "model/genericModel.jar",
(flinkDeploymentManager / crossTarget).value / "nussknacker-flink-manager.jar" -> "managers/nussknacker-flink-manager.jar",
(requestResponseRuntime / crossTarget).value / "nussknacker-request-response-manager.jar" -> "managers/nussknacker-request-response-manager.jar",
(liteEmbeddedDeploymentManager / crossTarget).value / "lite-embedded-manager.jar" -> "managers/lite-embedded-manager.jar",
(flinkBaseComponents / crossTarget).value / "flinkBase.jar" -> "components/flink/flinkBase.jar",
(flinkKafkaComponents / crossTarget).value / "flinkKafka.jar" -> "components/flink/flinkKafka.jar",
(liteBaseComponents / crossTarget).value / "liteBase.jar" -> "components/lite/liteBase.jar",
(liteKafkaComponents / crossTarget).value / "liteKafka.jar" -> "components/lite/liteKafka.jar",
(openapiComponents / crossTarget).value / "openapi.jar" -> "components/openapi.jar",
(sqlComponents / crossTarget).value / "sql.jar" -> "components/sql.jar"
),
/* //FIXME: figure out how to filter out only for .tgz, not for docker
mappings in Universal := {
val universalMappings = (mappings in Universal).value
//we don't want docker-* stuff in .tgz
universalMappings filterNot { case (file, _) =>
file.getName.startsWith("docker-") ||file.getName.contains("entrypoint.sh")
}
},*/
publishArtifact := false,
SettingsHelper.makeDeploymentSettings(Universal, Universal / packageZipTarball, "tgz")
)
.settings(distDockerSettings)
.dependsOn(ui)
if (addDevModel) {
module
.settings(
Compile / Keys.compile := (Compile / Keys.compile).dependsOn(
flinkManagementSample / Compile / assembly,
requestResponseSample / Compile / assembly,
liteModel / Compile / assembly
).value,
Universal / mappings += {
val genericModel = (flinkManagementSample / crossTarget).value / "managementSample.jar"
genericModel -> "model/managementSample.jar"
},
Universal / mappings += {
val demoModel = (requestResponseSample / crossTarget).value / s"requestResponseSample.jar"
demoModel -> "model/requestResponseSample.jar"
},
Universal /mappings += {
((liteModel / crossTarget).value / "liteModel.jar") -> "model/liteModel.jar"
}
)
} else {
module
}
}
def engine(name: String) = file(s"engine/$name")
def flink(name: String) = engine(s"flink/$name")
def lite(name: String) = engine(s"lite/$name")
def component(name: String) = file(s"components/$name")
def utils(name: String) = file(s"utils/$name")
def itSettings() = {
Defaults.itSettings ++ Seq(IntegrationTest / testOptions += scalaTestReports)
}
lazy val requestResponseRuntime = (project in lite("request-response/runtime")).
configs(IntegrationTest).
settings(itSettings()).
settings(commonSettings).
settings(assemblyNoScala("nussknacker-request-response-manager.jar"): _*).
settings(
name := "nussknacker-request-response-runtime",
IntegrationTest / Keys.test := (IntegrationTest / Keys.test).dependsOn(
requestResponseSample / Compile / assembly
).value,
).
dependsOn(liteEngineRuntime, requestResponseApi, deploymentManagerApi, httpUtils % "provided", testUtil % "it,test", requestResponseUtil % "test", liteBaseComponents % "test")
lazy val requestResponseDockerSettings = {
val workingDir = "/opt/nussknacker"
commonDockerSettings ++ Seq(
dockerEntrypoint := Seq(s"$workingDir/bin/nussknacker-request-response-entrypoint.sh"),
dockerExposedPorts := Seq(
requestResponseProcessesPort,
requestResponseManagementPort
),
dockerExposedVolumes := Seq(s"$workingDir/storage"),
Docker / defaultLinuxInstallLocation := workingDir,
packageName := requestResponseDockerPackageName,
dockerLabels := Map(
"version" -> version.value,
"scala" -> scalaVersion.value,
)
)
}
lazy val requestResponseApp = (project in lite("request-response/app")).
settings(commonSettings).
settings(publishAssemblySettings: _*).
enablePlugins(SbtNativePackager, JavaServerAppPackaging).
settings(
name := "nussknacker-request-response-app",
assembly / assemblyOption := (assembly / assemblyOption).value.copy(includeScala = true, level = Level.Info),
assembly / assemblyMergeStrategy := requestResponseMergeStrategy,
libraryDependencies ++= {
Seq(
"de.heikoseeberger" %% "akka-http-circe" % akkaHttpCirceV,
"com.typesafe.akka" %% "akka-http" % akkaHttpV,
"com.typesafe.akka" %% "akka-stream" % akkaV,
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpV % "test",
"com.typesafe.akka" %% "akka-testkit" % akkaV % "test",
"com.typesafe.akka" %% "akka-slf4j" % akkaV,
"ch.qos.logback" % "logback-classic" % logbackV
)
}
).
settings(requestResponseDockerSettings).
dependsOn(requestResponseRuntime, interpreter, testUtil % "test", requestResponseUtil % "test")
lazy val flinkDeploymentManager = (project in flink("management")).
configs(IntegrationTest).
settings(commonSettings).
settings(itSettings()).
settings(assemblyNoScala("nussknacker-flink-manager.jar"): _*).
settings(
name := "nussknacker-flink-manager",
IntegrationTest / Keys.test := (IntegrationTest / Keys.test).dependsOn(
flinkManagementSample / Compile / assembly,
managementJavaSample / Compile / assembly,
flinkBaseComponents / Compile / assembly,
flinkKafkaComponents / Compile /assembly
).value,
//flink cannot run tests and deployment concurrently
IntegrationTest / parallelExecution := false,
libraryDependencies ++= {
Seq(
"org.typelevel" %% "cats-core" % catsV % "provided",
"org.apache.flink" %% "flink-streaming-scala" % flinkV % flinkScope
excludeAll(
ExclusionRule("log4j", "log4j"),
ExclusionRule("org.slf4j", "slf4j-log4j12")
),
"org.apache.flink" %% "flink-statebackend-rocksdb" % flinkV % flinkScope,
"com.softwaremill.sttp.client" %% "async-http-client-backend-future" % sttpV % "it,test",
//TODO: move to testcontainers, e.g. https://ci.apache.org/projects/flink/flink-docs-master/api/java/org/apache/flink/tests/util/flink/FlinkContainer.html
"com.whisk" %% "docker-testkit-scalatest" % "0.9.0" % "it,test",
"com.whisk" %% "docker-testkit-impl-spotify" % "0.9.0" % "it,test",
//dependencies below are just for QueryableStateTest
"org.apache.flink" % "flink-queryable-state-runtime" % flinkV % "test",
)
}
).dependsOn(deploymentManagerApi % "provided",
api % "provided",
httpUtils % "provided",
kafkaTestUtil % "it,test")
lazy val flinkPeriodicDeploymentManager = (project in flink("management/periodic")).
settings(commonSettings).
settings(assemblyNoScala("nussknacker-flink-periodic-manager.jar"): _*).
settings(
name := "nussknacker-flink-periodic-manager",
libraryDependencies ++= {
Seq(
"org.typelevel" %% "cats-core" % catsV % "provided",
"com.typesafe.slick" %% "slick" % slickV % "provided",
"com.typesafe.slick" %% "slick-hikaricp" % slickV % "provided, test",
"org.hsqldb" % "hsqldb" % hsqldbV % "test",
"org.flywaydb" % "flyway-core" % flywayV % "provided",
"com.cronutils" % "cron-utils" % cronParserV,
"com.typesafe.akka" %% "akka-actor" % akkaV,
)
}
).dependsOn(flinkDeploymentManager,
deploymentManagerApi % "provided",
api % "provided",
httpUtils % "provided",
testUtil % "test")
lazy val requestResponseSample = (project in lite("request-response/runtime/sample")).
settings(commonSettings).
settings(assemblyNoScala("requestResponseSample.jar"): _*).
settings(
name := "nussknacker-request-response-sample"
).dependsOn(util, requestResponseApi, requestResponseUtil)
lazy val flinkManagementSample = (project in flink("management/sample")).
settings(commonSettings).
settings(assemblyNoScala("managementSample.jar"): _*).
settings(
name := "nussknacker-management-sample" ,
libraryDependencies ++= {
Seq(
"com.cronutils" % "cron-utils" % cronParserV,
"javax.validation" % "validation-api" % javaxValidationApiV,
"org.apache.flink" %% "flink-streaming-scala" % flinkV % "provided",
"org.apache.flink" % "flink-queryable-state-runtime" % flinkV % "test",
"org.apache.flink" % "flink-runtime" % flinkV % "compile" classifier "tests"
)
}
).
dependsOn(avroFlinkUtil,
flinkEngine % "runtime",
//TODO: NodeAdditionalInfoProvider & ComponentExtractor should probably be moved to API?
interpreter % "provided",
flinkTestUtil % "test",
kafkaTestUtil % "test")
lazy val managementJavaSample = (project in flink("management/java_sample")).
settings(commonSettings).
settings(assemblyNoScala("managementJavaSample.jar"): _*).
settings(
name := "nussknacker-management-java-sample",
libraryDependencies ++= {
Seq(
"org.scala-lang.modules" %% "scala-java8-compat" % scalaCompatV,
"org.apache.flink" %% "flink-streaming-scala" % flinkV % "provided"
)
}
).dependsOn(flinkUtil, flinkEngine % "runtime")
lazy val generic = (project in flink("generic")).
settings(commonSettings).
settings(assemblyNoScala("genericModel.jar"): _*).
settings(publishAssemblySettings: _*).
settings(
name := "nussknacker-generic-model",
libraryDependencies ++= {
Seq(
"org.apache.flink" %% "flink-streaming-scala" % flinkV % "provided",
"org.apache.flink" %% "flink-statebackend-rocksdb" % flinkV % "provided"
)
})
.dependsOn(modelUtil,
//TODO: remove flinkEngine dependency in runtime, should be handled with adding flinkEngine to classpath
flinkEngine % "runtime,test",
interpreter % "provided",
flinkKafkaComponents % "test",
flinkBaseComponents % "test",
flinkTestUtil % "test",
kafkaTestUtil % "test",
//for local development
ui % "test",
deploymentManagerApi % "test")
lazy val flinkEngine = (project in flink("engine")).
settings(commonSettings).
settings(
name := "nussknacker-flink-engine",
libraryDependencies ++= {
Seq(
"org.apache.flink" %% "flink-streaming-scala" % flinkV % "provided",
"org.apache.flink" % "flink-runtime" % flinkV % "provided",
"org.apache.flink" %% "flink-statebackend-rocksdb" % flinkV % "provided"
)
}
).dependsOn(flinkUtil, interpreter, flinkTestUtil % "test")
lazy val interpreter = (project in file("interpreter")).
settings(commonSettings).
settings(
name := "nussknacker-interpreter",
libraryDependencies ++= {
Seq(
"org.springframework" % "spring-expression" % springV,
//needed by scala-compiler for spring-expression...
"com.google.code.findbugs" % "jsr305" % "3.0.2",
"javax.validation" % "validation-api" % javaxValidationApiV,
"org.scala-lang.modules" %% "scala-java8-compat" % scalaCompatV,
"org.apache.avro" % "avro" % avroV % "test",
"org.scalacheck" %% "scalacheck" % scalaCheckV % "test",
"com.cronutils" % "cron-utils" % cronParserV % "test"
)
}
).
dependsOn(util, testUtil % "test")
lazy val benchmarks = (project in file("benchmarks")).
settings(commonSettings).
enablePlugins(JmhPlugin).
settings(
name := "nussknacker-benchmarks",
libraryDependencies ++= {
Seq(
"org.apache.flink" %% "flink-streaming-scala" % flinkV,
"org.apache.flink" % "flink-runtime" % flinkV
)
},
// To avoid Intellij message that jmh generated classes are shared between main and test
Jmh / classDirectory := (Test / classDirectory).value,
Jmh / dependencyClasspath := (Test / dependencyClasspath).value,
Jmh / generateJmhSourcesAndResources := (Jmh / generateJmhSourcesAndResources).dependsOn(Test / compile).value,
).dependsOn(interpreter, avroFlinkUtil, flinkEngine, flinkBaseComponents, testUtil % "test")
lazy val kafkaUtil = (project in utils("kafka-util")).
configs(IntegrationTest).
settings(commonSettings).
settings(itSettings()).
settings(
name := "nussknacker-kafka-util",
libraryDependencies ++= {
Seq(
"javax.validation" % "validation-api" % javaxValidationApiV,
"org.apache.kafka" % "kafka-clients" % kafkaV,
"com.dimafeng" %% "testcontainers-scala-scalatest" % testcontainersScalaV % "it",
"com.dimafeng" %% "testcontainers-scala-kafka" % testcontainersScalaV % "it",
"org.scalatest" %% "scalatest" % scalaTestV % "it, test"
)
}
).dependsOn(util)
lazy val avroUtil = (project in utils("avro-util")).
settings(commonSettings).
settings(
name := "nussknacker-avro-util",
libraryDependencies ++= {
Seq(
"io.confluent" % "kafka-avro-serializer" % confluentV excludeAll (
ExclusionRule("log4j", "log4j"),
ExclusionRule("org.slf4j", "slf4j-log4j12")
),
// it is workaround for missing VerifiableProperties class - see https://github.com/confluentinc/schema-registry/issues/553
"org.apache.kafka" %% "kafka" % kafkaV % "provided" excludeAll (
ExclusionRule("log4j", "log4j"),
ExclusionRule("org.slf4j", "slf4j-log4j12")
),
"tech.allegro.schema.json2avro" % "converter" % "0.2.10",
"org.scalatest" %% "scalatest" % scalaTestV % "test"
)
}
).dependsOn(kafkaUtil, interpreter % Provided, kafkaTestUtil % "test")
lazy val avroFlinkUtil = (project in flink("avro-util")).
settings(commonSettings).
settings(
name := "nussknacker-flink-avro-util",
libraryDependencies ++= {
Seq(
"org.apache.flink" %% "flink-streaming-scala" % flinkV % "provided",
"org.apache.flink" % "flink-avro" % flinkV,
"org.apache.flink" %% s"flink-connector-kafka" % flinkV % "test",
"org.scalatest" %% "scalatest" % scalaTestV % "test"
)
}
)
.dependsOn(avroUtil, flinkKafkaUtil, interpreter % Provided, kafkaTestUtil % "test", flinkTestUtil % "test", flinkEngine % "test")
lazy val flinkKafkaUtil = (project in flink("kafka-util")).
settings(commonSettings).
settings(
name := "nussknacker-flink-kafka-util",
libraryDependencies ++= {
Seq(
"org.apache.flink" %% "flink-connector-kafka" % flinkV,
"org.apache.flink" %% "flink-streaming-scala" % flinkV % "provided",
"org.scalatest" %% "scalatest" % scalaTestV % "test"
)
}
).
dependsOn(kafkaUtil, flinkUtil, flinkEngine % "test", kafkaTestUtil % "test", flinkTestUtil % "test")
lazy val kafkaTestUtil = (project in utils("kafka-test-util")).
settings(commonSettings).
settings(
name := "nussknacker-kafka-test-util",
libraryDependencies ++= {
Seq(
"org.apache.kafka" %% "kafka" % kafkaV excludeAll (
ExclusionRule("log4j", "log4j"),
ExclusionRule("org.slf4j", "slf4j-log4j12")
),
"org.slf4j" % "log4j-over-slf4j" % slf4jV
)
}
)
.dependsOn(testUtil, kafkaUtil)
lazy val util = (project in utils("util")).
settings(commonSettings).
settings(
name := "nussknacker-util",
libraryDependencies ++= {
Seq(
"org.springframework" % "spring-core" % springV,
"com.github.ben-manes.caffeine" % "caffeine" % caffeineCacheV,
"org.scala-lang.modules" %% "scala-java8-compat" % scalaCompatV,
"com.iheart" %% "ficus" % ficusV
)
}
).dependsOn(api, testUtil % "test")
lazy val modelUtil = (project in utils("model-util")).
settings(commonSettings).
settings(
name := "nussknacker-model-util"
).dependsOn(util, testUtil % "test", interpreter % "test")
lazy val testUtil = (project in utils("test-util")).
settings(commonSettings).
settings(
name := "nussknacker-test-util",
libraryDependencies ++= {
Seq(
"org.scalatest" %% "scalatest" % scalaTestV,
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingV,
"com.typesafe" % "config" % configV,
"ch.qos.logback" % "logback-classic" % logbackV
)
}
)
lazy val flinkUtil = (project in flink("util")).
settings(commonSettings).
settings(
name := "nussknacker-flink-util",
libraryDependencies ++= {
Seq(
"org.apache.flink" %% "flink-streaming-scala" % flinkV % "provided",
"org.apache.flink" % "flink-metrics-dropwizard" % flinkV,
"com.clearspring.analytics" % "stream" % "2.9.8" excludeAll (
//It is used only in QDigest which we don't use, while it's >20MB in size...
ExclusionRule("it.unimi.dsi", "fastutil"),
)
)
}
).dependsOn(util, flinkApi, testUtil % "test")
lazy val flinkTestUtil = (project in flink("test-util")).
settings(commonSettings).
settings(
name := "nussknacker-flink-test-util",
libraryDependencies ++= {
Seq(
"org.apache.flink" %% "flink-streaming-scala" % flinkV % "provided",
//intellij has some problems with provided...
"org.apache.flink" %% "flink-statebackend-rocksdb" % flinkV,
"org.apache.flink" %% "flink-test-utils" % flinkV excludeAll (
//we use logback in NK
ExclusionRule("org.apache.logging.log4j", "log4j-slf4j-impl")
),
"org.apache.flink" % "flink-runtime" % flinkV % "compile" classifier "tests",
"org.apache.flink" % "flink-metrics-dropwizard" % flinkV
)
}
).dependsOn(testUtil, flinkUtil, interpreter)
lazy val requestResponseUtil = (project in lite("request-response/util")).
settings(commonSettings).
settings(
name := "nussknacker-request-response-util"
).dependsOn(util, requestResponseApi, testUtil % "test")
lazy val requestResponseApi = (project in lite("request-response/api")).
settings(commonSettings).
settings(
name := "nussknacker-request-response-api"
).dependsOn(liteEngineApi)
lazy val liteEngineApi = (project in lite("api")).
settings(commonSettings).
settings(
name := "nussknacker-lite-api",
).dependsOn(api)
lazy val liteBaseComponents = (project in lite("components/base")).
settings(commonSettings).
settings(assemblyNoScala("liteBase.jar"): _*).
settings(
name := "nussknacker-lite-base-components",
).dependsOn(liteEngineApi % "provided")
lazy val liteKafkaComponents = (project in lite("components/kafka")).
settings(commonSettings).
settings(assemblyNoScala("liteKafka.jar"): _*).
settings(
name := "nussknacker-lite-kafka-components",
//TODO: avroUtil brings kafkaUtil to assembly, which is superfluous, as we already have it in engine...
).dependsOn(liteEngineKafkaApi % "provided", liteEngineApi % "provided", avroUtil)
lazy val liteEngineRuntime = (project in lite("runtime")).
settings(commonSettings).
settings(
name := "nussknacker-lite-runtime",
libraryDependencies ++= {
Seq(
"io.dropwizard.metrics5" % "metrics-core" % dropWizardV,
"io.dropwizard.metrics5" % "metrics-influxdb" % dropWizardV,
"com.softwaremill.sttp.client" %% "core" % sttpV,
"ch.qos.logback" % "logback-classic" % logbackV,
)
},
).dependsOn(liteEngineApi, interpreter, testUtil % "test")
lazy val liteEngineKafkaIntegrationTest: Project = (project in lite("kafka/integration-test")).
configs(IntegrationTest).
settings(itSettings()).
settings(commonSettings).
settings(
name := "nussknacker-lite-kafka-integration-test",
IntegrationTest / Keys.test := (IntegrationTest / Keys.test).dependsOn(
liteEngineKafkaRuntime / Universal / stage,
liteEngineKafkaRuntime / Docker / publishLocal
).value,
libraryDependencies ++= Seq(
"commons-io" % "commons-io" % commonsIOV,
"com.dimafeng" %% "testcontainers-scala-scalatest" % testcontainersScalaV % "it",
"com.dimafeng" %% "testcontainers-scala-kafka" % testcontainersScalaV % "it"
)
).dependsOn(interpreter % "it", kafkaUtil % "it", testUtil % "it", kafkaTestUtil % "it")
lazy val liteEngineKafkaApi = (project in lite("kafka/api")).
settings(commonSettings).
settings(
name := "nussknacker-lite-kafka-api",
libraryDependencies ++= Seq(
"org.apache.kafka" % "kafka-clients" % kafkaV
)
).dependsOn(api)
lazy val liteEngineKafkaRuntimeDockerSettings = {
val workingDir = "/opt/nussknacker"
commonDockerSettings ++ Seq(
dockerEntrypoint := Seq(s"$workingDir/bin/nu-kafka-engine-entrypoint.sh"),
Docker / defaultLinuxInstallLocation := workingDir,
packageName := liteEngineKafkaRuntimeDockerPackageName,
dockerLabels := Map(
"version" -> version.value,
"scala" -> scalaVersion.value,
)
)
}
lazy val liteEngineKafkaRuntime: Project = (project in lite("kafka/runtime")).
settings(commonSettings).
settings(liteEngineKafkaRuntimeDockerSettings).
enablePlugins(SbtNativePackager, JavaServerAppPackaging).
settings(
name := "nussknacker-lite-kafka-runtime",
Compile / Keys.compile := (Compile / Keys.compile).dependsOn(
liteModel / Compile / assembly,
openapiComponents / Compile / assembly,
sqlComponents / Compile / assembly,
liteBaseComponents / Compile / assembly,
liteKafkaComponents / Compile / assembly,
).value,
Universal / mappings ++= Seq(
(liteModel / crossTarget).value / "liteModel.jar" -> "model/liteModel.jar",
(liteBaseComponents / crossTarget).value / "liteBase.jar" -> "components/lite/liteBase.jar",
(liteKafkaComponents / crossTarget).value / "liteKafka.jar" -> "components/lite/liteKafka.jar",
(openapiComponents / crossTarget).value / "openapi.jar" -> "components/openapi.jar",
(sqlComponents / crossTarget).value / "sql.jar" -> "components/sql.jar"
),
libraryDependencies ++= Seq(
"commons-io" % "commons-io" % commonsIOV
)
).dependsOn(liteEngineRuntime, liteEngineKafkaApi, kafkaUtil, testUtil % "test", kafkaTestUtil % "test", liteBaseComponents % "test")
lazy val liteModel = (project in lite("model")).
settings(commonSettings).
settings(assemblyNoScala("liteModel.jar"): _*).
settings(
name := "nussknacker-lite-model"
).dependsOn(api, modelUtil)
lazy val liteEmbeddedDeploymentManager = (project in lite("embeddedDeploymentManager")).
configs(IntegrationTest).
settings(itSettings()).
enablePlugins().
settings(commonSettings).
settings(assemblyNoScala("lite-embedded-manager.jar"): _*).
settings(
name := "lite-embedded-deploymentManager",
).dependsOn(liteEngineKafkaRuntime, deploymentManagerApi % "provided", testUtil % "test", kafkaTestUtil % "test")
lazy val api = (project in file("api")).
settings(commonSettings).
enablePlugins(BuildInfoPlugin).
settings(
buildInfoKeys := Seq[BuildInfoKey](name, version),
buildInfoKeys ++= Seq[BuildInfoKey](
"buildTime" -> java.time.LocalDateTime.now().toString,
"gitCommit" -> git.gitHeadCommit.value.getOrElse("")
),
buildInfoPackage := "pl.touk.nussknacker.engine.version",
buildInfoOptions ++= Seq(BuildInfoOption.ToMap)
).
settings(
name := "nussknacker-api",
libraryDependencies ++= {
Seq(
"io.circe" %% "circe-parser" % circeV,
"io.circe" %% "circe-generic" % circeV,
"io.circe" %% "circe-generic-extras" % circeV,
"com.github.erosb" % "everit-json-schema" % everitSchemaV,
"com.iheart" %% "ficus" % ficusV,
"org.apache.commons" % "commons-lang3" % commonsLangV,
"org.apache.commons" % "commons-text" % commonsTextV,
"org.typelevel" %% "cats-core" % catsV,
"org.typelevel" %% "cats-effect" % "2.5.3",
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingV,
"com.typesafe" % "config" % configV,
"com.vdurmont" % "semver4j" % "3.1.0"
)
}
).dependsOn(testUtil % "test")
lazy val security = (project in file("security")).
configs(IntegrationTest).
settings(commonSettings).
settings(itSettings()).
settings(
name := "nussknacker-security",
libraryDependencies ++= {
Seq(
"com.typesafe.akka" %% "akka-http" % akkaHttpV,
"com.typesafe.akka" %% "akka-stream" % akkaV,
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpV % "test",
"com.typesafe.akka" %% "akka-testkit" % akkaV % "test",
"de.heikoseeberger" %% "akka-http-circe" % akkaHttpCirceV,
"com.typesafe" % "config" % configV ,
"org.mindrot" % "jbcrypt" % jbcryptV,
//Packages below are only for plugin providers purpose
"io.circe" %% "circe-core" % circeV,
"com.github.jwt-scala" %% "jwt-circe" % jwtCirceV,
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingV,
"com.auth0" % "jwks-rsa" % "0.19.0", // a tool library for reading a remote JWK store, not an Auth0 service dependency
"com.softwaremill.sttp.client" %% "async-http-client-backend-future" % sttpV % "it,test",
"com.dimafeng" %% "testcontainers-scala-scalatest" % testcontainersScalaV % "it,test",
"com.github.dasniko" % "testcontainers-keycloak" % "1.6.0" % "it,test"
)
}
)
.dependsOn(util, httpUtils, testUtil % "it,test")
lazy val flinkApi = (project in flink("api")).
settings(commonSettings).
settings(
name := "nussknacker-flink-api",
libraryDependencies ++= {
Seq(