-
Notifications
You must be signed in to change notification settings - Fork 66
/
build.sbt
1163 lines (1077 loc) · 36.6 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 scalajsbundler.JSDOMNodeJSEnv
import xerial.sbt.pack.PackPlugin.{projectSettings, publishPackArchiveTgz}
val SCALA_2_12 = "2.12.20"
val SCALA_2_13 = "2.13.15"
val SCALA_3 = sys.env.getOrElse("SCALA_VERSION", "3.3.4")
val uptoScala2 = SCALA_2_13 :: SCALA_2_12 :: Nil
val targetScalaVersions = SCALA_3 :: uptoScala2
// Add this for using snapshot versions
ThisBuild / resolvers ++= Resolver.sonatypeOssRepos("snapshots")
val AIRSPEC_VERSION = sys.env.getOrElse("AIRSPEC_VERSION", "24.11.0")
val SCALACHECK_VERSION = "1.18.1"
val MSGPACK_VERSION = "0.9.8"
val SCALA_PARSER_COMBINATOR_VERSION = "2.4.0"
val SQLITE_JDBC_VERSION = "3.47.0.0"
val SLF4J_VERSION = "2.0.16"
val JS_JAVA_LOGGING_VERSION = "1.0.0"
val JS_JAVA_TIME_VERSION = "1.0.0"
val SCALAJS_DOM_VERSION = "2.8.0"
val FINAGLE_VERSION = "24.2.0"
val FLUENCY_VERSION = "2.7.3"
val GRPC_VERSION = "1.68.1"
val JMH_VERSION = "1.37"
val JAVAX_ANNOTATION_API_VERSION = "1.3.2"
val PARQUET_VERSION = "1.14.4"
val SNAKE_YAML_VERSION = "2.3"
val AIRFRAME_BINARY_COMPAT_VERSION = "23.6.0"
// A short cut for publishing snapshots to Sonatype
addCommandAlias(
"publishSnapshots",
s"+ projectJVM/publish; + projectJS/publish; + projectNative/publish"
)
// [Development purpose] publish all artifacts to the local repo
addCommandAlias(
"publishAllLocal",
s"+ projectJVM/publishLocal; + projectJS/publishLocal; + projectNative/publishLocal"
)
// [Development purpose] publish all sbt-airframe related artifacts to local repo
addCommandAlias(
"publishSbtDevLocal",
s"++ 2.12; projectJVM/publishLocal; ++ 3; projectDotty/publishLocal; projectJS/publishLocal"
)
addCommandAlias(
"publishJSSigned",
s"+ projectJS/publishSigned"
)
addCommandAlias(
"publishJSLocal",
s"+ projectJS/publishLocal"
)
addCommandAlias(
"publishNativeSigned",
s"+ projectNative/publishSigned"
)
// Allow using Ctrl+C in sbt without exiting the prompt
// Global / cancelable := true
//ThisBuild / turbo := true
// Reload build.sbt on changes
Global / onChangedBuildSource := ReloadOnSourceChanges
// ideSkipProject is used only for IntelliJ IDEA
Global / excludeLintKeys ++= Set(ideSkipProject)
// Disable the pipelining available since sbt-1.4.0. It caused compilation failure
ThisBuild / usePipelining := false
// Use Scala 3 by default as scala-2 specific source code is relatively small now
ThisBuild / scalaVersion := SCALA_3
ThisBuild / organization := "org.wvlet.airframe"
// Use dynamic snapshot version strings for non tagged versions
ThisBuild / dynverSonatypeSnapshots := true
// Use coursier friendly version separator
ThisBuild / dynverSeparator := "-"
val buildSettings = Seq[Setting[?]](
licenses += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html")),
homepage := Some(url("https://wvlet.org/airframe")),
scmInfo := Some(
ScmInfo(
browseUrl = url("https://github.com/wvlet/airframe"),
connection = "scm:git@github.com:wvlet/airframe.git"
)
),
developers := List(
Developer(id = "leo", name = "Taro L. Saito", email = "leo@xerial.org", url = url("http://xerial.org/leo"))
),
// Exclude compile-time only projects. This is a workaround for bloop,
// which cannot resolve Optional dependencies nor compile-internal dependencies.
pomPostProcess := excludePomDependency(Seq("airspec_2.12", "airspec_2.13", "airspec_3")),
crossScalaVersions := targetScalaVersions,
crossPaths := true,
publishMavenStyle := true,
mimaPreviousArtifacts := Set("org.wvlet.airframe" %%% s"${name.value}" % AIRFRAME_BINARY_COMPAT_VERSION),
mimaFailOnNoPrevious := false,
mimaBinaryIssueFilters ++= {
import com.typesafe.tools.mima.core.*
Seq(
ProblemFilters.exclude[MissingClassProblem]("wvlet.airframe.http.internal.*")
)
},
javacOptions ++= Seq("-source", "11", "-target", "11"),
scalacOptions ++= Seq(
"-feature",
"-deprecation"
// Use this flag for debugging Macros
// "-Xcheck-macros",
) ++ {
if (scalaVersion.value.startsWith("3.")) {
Seq.empty
} else {
Seq(
// Necessary for tracking source code range in airframe-rx demo
"-Yrangepos",
// For using the new import * syntax even in Scala 2.x
"-Xsource:3"
)
}
},
testFrameworks += new TestFramework("wvlet.airspec.Framework"),
libraryDependencies ++= Seq(
"org.wvlet.airframe" %%% "airspec" % AIRSPEC_VERSION % Test,
"org.scalacheck" %%% "scalacheck" % SCALACHECK_VERSION % Test
) ++ {
if (scalaVersion.value.startsWith("3."))
Seq.empty
else
Seq("org.scala-lang.modules" %%% "scala-collection-compat" % "2.12.0")
}
)
val scala2Only = Seq[Setting[?]](
scalaVersion := SCALA_2_13,
crossScalaVersions := uptoScala2
)
val scala3Only = Seq[Setting[?]](
scalaVersion := SCALA_3,
crossScalaVersions := List(SCALA_3)
)
// Do not run tests concurrently to avoid JMX registration failures
val runTestSequentially = Seq[Setting[?]](Test / parallelExecution := false)
// We need to define this globally as a workaround for https://github.com/sbt/sbt/pull/3760
ThisBuild / publishTo := sonatypePublishToBundle.value
val jsBuildSettings = Seq[Setting[?]](
// #2117 For using java.util.UUID.randomUUID() in Scala.js
libraryDependencies ++= Seq(
("org.scala-js" %%% "scalajs-java-securerandom" % "1.0.0" % Test).cross(CrossVersion.for3Use2_13),
// TODO It should be included in AirSpec
"org.scala-js" %%% "scala-js-macrotask-executor" % "1.1.1" % Test
),
coverageEnabled := false
)
val nativeBuildSettings = Seq[Setting[?]](
scalaVersion := SCALA_3,
crossScalaVersions := List(SCALA_3),
coverageEnabled := false
// nativeConfig ~= {
// _.withSourceLevelDebuggingConfig(_.enableAll) // enable generation of debug informations
// .withOptimize(false) // disable Scala Native optimizer
// .withMode(scalanative.build.Mode.debug) // compile using LLVM without optimizations
// }
)
val noPublish = Seq(
publishArtifact := false,
publish := {},
publishLocal := {},
publish / skip := true,
// This must be Nil to use crossScalaVersions of individual modules in `+ projectJVM/xxxx` tasks
crossScalaVersions := Nil,
// Explicitly skip the doc task because protobuf related Java files causes no type found error
Compile / doc / sources := Seq.empty,
Compile / packageDoc / publishArtifact := false,
// Do not check binary compatibility for unpublished projects
mimaPreviousArtifacts := Set.empty
)
Global / excludeLintKeys ++= Set(sonatypeProfileName, sonatypeSessionName)
lazy val root =
project
.in(file("."))
.settings(name := "airframe-root")
.settings(buildSettings)
.settings(noPublish)
.settings(
sonatypeProfileName := "org.wvlet",
sonatypeSessionName := {
// Use different session names for parallel publishing to Sonatype
if (sys.env.isDefinedAt("SCALA_JS")) {
s"${sonatypeSessionName.value} for Scala.js"
} else if (sys.env.isDefinedAt("SCALA_NATIVE")) {
s"${sonatypeSessionName.value} for Scala Native"
} else {
sonatypeSessionName.value
}
}
)
.aggregate((jvmProjects ++ jsProjects ++ itProjects): _*)
// JVM projects for scala-community build. This should have no tricky setup and should support Scala 2.12 and Scala 3
lazy val communityBuildProjects: Seq[ProjectReference] = Seq(
canvas,
config,
control.jvm,
codec.jvm,
diMacros.jvm,
di.jvm,
fluentd,
grpc,
http.jvm,
httpCodeGen,
httpRecorder,
jdbc,
jmx,
json.jvm,
log.jvm,
launcher,
metrics.jvm,
msgpack.jvm,
netty,
okhttp,
parquet,
rx.jvm,
rxHtml.jvm,
surface.jvm,
ulid.jvm,
examples
)
// Other JVM projects supporting Scala 2.12 - Scala 2.13
lazy val jvmProjects: Seq[ProjectReference] = communityBuildProjects ++ Seq[ProjectReference](
finagle,
benchmark,
sql
)
// Scala.js build (Scala 2.12, 2.13, and 3.x)
lazy val jsProjects: Seq[ProjectReference] = Seq(
log.js,
surface.js,
diMacros.js,
di.js,
metrics.js,
control.js,
ulid.js,
json.js,
msgpack.js,
codec.js,
http.js,
rx.js,
rxHtml.js,
widgetJS
)
lazy val nativeProjects: Seq[ProjectReference] = Seq(
log.native,
surface.native,
diMacros.native,
di.native,
metrics.native,
json.native,
msgpack.native,
ulid.native,
rx.native,
control.native,
codec.native,
http.native
)
// Integration test projects
lazy val itProjects: Seq[ProjectReference] = Seq(
integrationTestApi.jvm,
integrationTestApi.js,
integrationTest,
integrationTestJs
)
// For community-build
lazy val communityBuild =
project
.settings(noPublish)
.settings(
// Skip importing aggregated projects in IntelliJ IDEA
ideSkipProject := true
)
.aggregate(communityBuildProjects: _*)
// For Scala 2.12
lazy val projectJVM =
project
.settings(noPublish)
.settings(
// Skip importing aggregated projects in IntelliJ IDEA
ideSkipProject := true,
// Use a stable coverage directory name without containing scala version
coverageDataDir := target.value
)
.aggregate(jvmProjects: _*)
lazy val projectJS =
project
.settings(noPublish)
.settings(
// Skip importing aggregated projects in IntelliJ IDEA
ideSkipProject := true
)
.aggregate(jsProjects: _*)
lazy val projectNative =
project
.settings(noPublish)
.settings(
// Skip importing aggregated projects in IntelliJ IDEA
ideSkipProject := true
)
.aggregate(nativeProjects: _*)
lazy val projectIt =
project
.settings(noPublish)
.settings(
// Skip importing aggregated projects in IntelliJ IDEA
ideSkipProject := true
)
.aggregate(itProjects: _*)
// A scoped project only for Dotty (Scala 3).
// This is a workaround as projectJVM/test shows compile errors for non Scala 3 ready projects
lazy val projectDotty =
project
.settings(noPublish)
.settings(
// Skip importing aggregated projects in IntelliJ IDEA
ideSkipProject := true
)
.aggregate(
diMacros.jvm,
di.jvm,
log.jvm,
surface.jvm,
canvas,
control.jvm,
config,
codec.jvm,
fluentd,
http.jvm,
netty,
httpCodeGen,
httpRecorder,
okhttp,
// // Finagle isn't supporting Scala 3
// httpFinagle,
grpc,
jdbc,
jmx,
launcher,
metrics.jvm,
msgpack.jvm,
json.jvm,
parquet,
rx.jvm,
rxHtml.jvm,
sql,
ulid.jvm,
examples
)
lazy val docs =
project
.in(file("airframe-docs"))
.settings(
name := "airframe-docs",
moduleName := "airframe-docs",
publishArtifact := false,
publish := {},
publishLocal := {},
mdoc / watchTriggers += ((ThisBuild / baseDirectory).value / "docs").toGlob / ** / "*.md"
)
.enablePlugins(MdocPlugin, DocusaurusPlugin)
def parallelCollection(scalaVersion: String) = {
if (scalaVersion.startsWith("2.13.")) {
Seq("org.scala-lang.modules" %% "scala-parallel-collections" % "0.2.0")
} else {
Seq.empty
}
}
// https://stackoverflow.com/questions/41670018/how-to-prevent-sbt-to-include-test-dependencies-into-the-pom
import scala.xml.{Node => XmlNode, NodeSeq => XmlNodeSeq, *}
import scala.xml.transform.{RewriteRule, RuleTransformer}
def excludePomDependency(excludes: Seq[String]) = { node: XmlNode =>
def isExcludeTarget(artifactId: String): Boolean =
excludes.exists(artifactId.startsWith(_))
def artifactId(e: Elem): Option[String] =
e.child.find(_.label == "artifactId").map(_.text.trim())
new RuleTransformer(new RewriteRule {
override def transform(node: XmlNode): XmlNodeSeq =
node match {
case e: Elem
if e.label == "dependency"
&& artifactId(e).exists(id => isExcludeTarget(id)) =>
Comment(s"Excluded compile-time only dependency: ${artifactId(e).getOrElse("")}")
case _ =>
node
}
}).transform(node).head
}
lazy val base =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("airframe-core-base"))
.settings(buildSettings)
.settings(scala3Only)
.settings(
name := "airframe-core-base",
description := "Macro and base module for airframe-core"
)
.jsSettings(jsBuildSettings)
.nativeSettings(nativeBuildSettings)
lazy val core =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("airframe-core"))
.settings(buildSettings)
.settings(scala3Only)
.settings(
name := "airframe-core",
description := "A new core module of Airframe for Scala 3"
)
.jvmSettings(
libraryDependencies ++= Seq(
// TODO Add pure-Scala/Java code for rotating log files
"ch.qos.logback" % "logback-core" % "1.5.8"
)
)
.jsSettings(jsBuildSettings)
.nativeSettings(nativeBuildSettings)
.dependsOn(base)
def airframeDIDependencies = Seq(
"javax.annotation" % "javax.annotation-api" % JAVAX_ANNOTATION_API_VERSION
)
lazy val di =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("airframe-di"))
.settings(buildSettings)
.settings(
name := "airframe",
description := "Dependency injection library tailored to Scala",
// For PreDestroy, PostConstruct annotations
libraryDependencies ++= airframeDIDependencies
)
.jvmSettings(
// Workaround for https://github.com/scala/scala/pull/7624 in Scala 2.13, and also
// testing shutdown hooks requires consistent application lifecycle between sbt and JVM https://github.com/sbt/sbt/issues/4794
Test / fork := scalaBinaryVersion.value == "2.13"
)
.jsSettings(
jsBuildSettings
)
.nativeSettings(
nativeBuildSettings
)
.dependsOn(
surface,
diMacros
)
def crossBuildSources(scalaBinaryVersion: String, baseDir: String, srcType: String = "main"): Seq[sbt.File] = {
val scalaMajorVersion = scalaBinaryVersion.split("\\.").head
for (suffix <- Seq("", s"-${scalaBinaryVersion}", s"-${scalaMajorVersion}").distinct)
yield {
file(s"${baseDir}/src/${srcType}/scala${suffix}")
}
}
// Airframe DI needs to call macro methods, so we needed to split the project into DI and DI macros.
// This project sources and classes will be embedded to airframe.jar, so we don't publish airframe-di-macros
lazy val diMacros =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("airframe-di-macros"))
.settings(buildSettings)
.settings(
name := "airframe-di-macros",
description := "Macros for Airframe Di"
)
.jsSettings(jsBuildSettings)
.nativeSettings(nativeBuildSettings)
.dependsOn(log, surface)
// // To use airframe in other airframe modules, we need to reference airframeMacros project
// lazy val airframeMacrosJVMRef = airframeMacrosJVM % Optional
// lazy val airframeMacrosRef = airframeMacros % Optional
val surfaceDependencies = { scalaVersion: String =>
scalaVersion match {
case s if s.startsWith("3.") =>
Seq.empty
case _ =>
Seq(
("org.scala-lang" % "scala-reflect" % scalaVersion),
("org.scala-lang" % "scala-compiler" % scalaVersion % Provided)
)
}
}
lazy val surface =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("airframe-surface"))
.settings(buildSettings)
.settings(
name := "airframe-surface",
description := "A library for extracting object structure surface",
// TODO: This is a temporary solution. Use AirSpec after Scala 3 support of Surface is completed
libraryDependencies ++= surfaceDependencies(scalaVersion.value)
)
.jvmSettings(
// For adding PreDestroy, PostConstruct annotations to Java9
libraryDependencies += "javax.annotation" % "javax.annotation-api" % JAVAX_ANNOTATION_API_VERSION % Test
)
.jsSettings(jsBuildSettings)
.nativeSettings(nativeBuildSettings)
.dependsOn(log)
lazy val canvas =
project
.in(file("airframe-canvas"))
.settings(buildSettings)
.settings(
name := "airframe-canvas",
description := "Airframe off-heap memory library"
)
.dependsOn(log.jvm, control.jvm % Test)
lazy val config =
project
.in(file("airframe-config"))
.settings(buildSettings)
.settings(
name := "airframe-config",
description := "airframe configuration module",
libraryDependencies ++= Seq(
"org.yaml" % "snakeyaml" % SNAKE_YAML_VERSION
)
)
.dependsOn(di.jvm, codec.jvm)
lazy val control =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("airframe-control"))
.settings(buildSettings)
.settings(
name := "airframe-control",
description := "A library for controlling program flows and retrying"
)
.jsSettings(jsBuildSettings)
.nativeSettings(nativeBuildSettings)
.dependsOn(log, rx)
lazy val ulid =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("airframe-ulid"))
.settings(buildSettings)
.settings(
name := "airframe-ulid",
description := "ULID: Universally Unique Lexicographically Sortable Identifier"
)
.jsSettings(
jsBuildSettings,
// For using SecureRandom (requires `crypto` package)
libraryDependencies += ("org.scala-js" %%% "scalajs-java-securerandom" % "1.0.0").cross(CrossVersion.for3Use2_13)
)
.nativeSettings(nativeBuildSettings)
.dependsOn(log % Test)
lazy val jmx =
project
.in(file("airframe-jmx"))
.settings(buildSettings)
.settings(
name := "airframe-jmx",
description := "A library for exposing Scala object data through JMX",
// Do not run tests concurrently to avoid JMX registration failures
runTestSequentially
)
.dependsOn(surface.jvm)
lazy val launcher =
project
.in(file("airframe-launcher"))
.settings(buildSettings)
.settings(
name := "airframe-launcher",
description := "Command-line program launcher"
)
.dependsOn(surface.jvm, control.jvm, codec.jvm)
val logDependencies = { scalaVersion: String =>
scalaVersion match {
case s if s.startsWith("3.") =>
Seq.empty
case _ =>
Seq("org.scala-lang" % "scala-reflect" % scalaVersion % Provided)
}
}
val logJVMDependencies = Seq(
// For rotating log files
"ch.qos.logback" % "logback-core" % "1.5.8"
)
// airframe-log should have minimum dependencies
lazy val log: sbtcrossproject.CrossProject =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("airframe-log"))
.settings(buildSettings)
.settings(
name := "airframe-log",
description := "Fancy logger for Scala",
scalacOptions ++= {
if (scalaVersion.value.startsWith("3.")) Seq("-source:3.0-migration")
else Nil
},
libraryDependencies ++= logDependencies(scalaVersion.value)
)
.jvmSettings(
libraryDependencies ++= logJVMDependencies,
runTestSequentially
)
.jsSettings(
jsBuildSettings,
libraryDependencies ++= Seq(
("org.scala-js" %%% "scalajs-java-logging" % JS_JAVA_LOGGING_VERSION).cross(CrossVersion.for3Use2_13)
)
)
.nativeSettings(
nativeBuildSettings
)
lazy val metrics =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("airframe-metrics"))
.settings(buildSettings)
.settings(
name := "airframe-metrics",
description := "Basit metric representations, including duration, size, time window, etc."
)
.jsSettings(jsBuildSettings)
.nativeSettings(nativeBuildSettings)
.dependsOn(log, surface)
lazy val msgpack =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("airframe-msgpack"))
.settings(buildSettings)
.settings(
name := "airframe-msgpack",
description := "Pure-Scala MessagePack library"
)
.jvmSettings(
libraryDependencies += "org.msgpack" % "msgpack-core" % MSGPACK_VERSION
)
.jsSettings(
jsBuildSettings,
libraryDependencies +=
("org.scala-js" %%% "scalajs-java-time" % JS_JAVA_TIME_VERSION).cross(CrossVersion.for3Use2_13)
)
.nativeSettings(
nativeBuildSettings,
// For using java.time libraries
libraryDependencies += "org.ekrich" %%% "sjavatime" % "1.3.0"
)
.dependsOn(log, json)
lazy val codec =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("airframe-codec"))
.settings(buildSettings)
.settings(
// TODO: #1698 Avoid "illegal multithreaded access to ContextBase error" on Scala 3
// Tests in this project are sequentially executed
// Test / parallelExecution := false,
name := "airframe-codec",
description := "Airframe MessagePack-based codec"
)
.jvmSettings(
libraryDependencies ++= Seq(
// For JDBC testing
"org.xerial" % "sqlite-jdbc" % SQLITE_JDBC_VERSION % Test
)
)
.jsSettings(
jsBuildSettings
)
.nativeSettings(nativeBuildSettings)
.dependsOn(log, surface, msgpack, metrics, json, control, ulid)
lazy val jdbc =
project
.in(file("airframe-jdbc"))
.settings(buildSettings)
.settings(
name := "airframe-jdbc",
description := "JDBC connection pool service",
libraryDependencies ++= Seq(
"org.xerial" % "sqlite-jdbc" % SQLITE_JDBC_VERSION,
"org.duckdb" % "duckdb_jdbc" % "1.1.3",
"org.postgresql" % "postgresql" % "42.7.4",
"com.zaxxer" % "HikariCP" % "6.2.1",
// For routing slf4j log to airframe-log
"org.slf4j" % "slf4j-jdk14" % SLF4J_VERSION
)
)
.dependsOn(di.jvm, control.jvm, config)
lazy val rx =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("airframe-rx"))
.settings(buildSettings)
.settings(
name := "airframe-rx",
description := "Reactive stream (Rx) interface"
)
.jvmSettings(
libraryDependencies ++= Seq(
"javax.annotation" % "javax.annotation-api" % JAVAX_ANNOTATION_API_VERSION % Test
)
)
.jsSettings(
jsBuildSettings,
// For addressing the fairness issue of the global ExecutorContext https://github.com/scala-js/scala-js/issues/4129
libraryDependencies += "org.scala-js" %%% "scala-js-macrotask-executor" % "1.1.1"
)
.nativeSettings(nativeBuildSettings)
.dependsOn(log)
lazy val http =
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.enablePlugins(BuildInfoPlugin)
.in(file("airframe-http"))
.settings(buildSettings)
.settings(
name := "airframe-http",
description := "REST and RPC Framework",
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "wvlet.airframe.http",
buildInfoObject := "AirframeHttpBuildInfo"
)
.jvmSettings(
libraryDependencies += "javax.annotation" % "javax.annotation-api" % JAVAX_ANNOTATION_API_VERSION % Test,
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, major)) if major <= 12 =>
Seq()
case _ =>
Seq("org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4")
}
}
)
.jsSettings(
jsBuildSettings,
Test / jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv(),
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % SCALAJS_DOM_VERSION
)
)
.nativeSettings(
nativeBuildSettings
)
.dependsOn(rx, control, surface, json, codec, di)
lazy val httpCodeGen =
project
.in(file("airframe-http-codegen"))
.enablePlugins(PackPlugin)
.settings(buildSettings)
.settings(
name := "airframe-http-codegen",
description := "REST and RPC code generator",
packMain := Map("airframe-http-code-generator" -> "wvlet.airframe.http.codegen.HttpCodeGenerator"),
packExcludeLibJars := Seq("airspec_2.12", "airspec_2.13", "airspec_3"),
libraryDependencies ++= Seq(
// Use swagger-parser only for validating YAML format in tests
"io.swagger.parser.v3" % "swagger-parser" % "2.1.24" % Test,
// Swagger includes dependency to SLF4J, so redirect slf4j logs to airframe-log
"org.slf4j" % "slf4j-jdk14" % SLF4J_VERSION % Test,
// For gRPC route scanner test
"io.grpc" % "grpc-stub" % GRPC_VERSION % Test
),
// Published package is necessary for sbt-airframe
publishPackArchiveTgz
)
.dependsOn(http.jvm, launcher)
lazy val netty =
project
.in(file("airframe-http-netty"))
.settings(buildSettings)
.settings(
name := "airframe-http-netty",
description := "Airframe HTTP Netty backend",
libraryDependencies ++= Seq(
"io.netty" % "netty-all" % "4.1.115.Final"
)
)
.dependsOn(http.jvm, rx.jvm)
lazy val grpc =
project
.in(file("airframe-http-grpc"))
.settings(buildSettings)
.settings(
name := "airframe-http-grpc",
description := "Airframe HTTP gRPC backend",
libraryDependencies ++= Seq(
"io.grpc" % "grpc-netty-shaded" % GRPC_VERSION,
"io.grpc" % "grpc-stub" % GRPC_VERSION,
"org.apache.tomcat" % "annotations-api" % "6.0.53" % Provided,
"org.slf4j" % "slf4j-jdk14" % SLF4J_VERSION % Test
)
)
.dependsOn(http.jvm, rx.jvm)
// Workaround for com.twitter:util-core_2.12:21.4.0 (depends on 1.1.2)
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % "always"
lazy val finagle =
project
.in(file("airframe-http-finagle"))
.settings(buildSettings)
.settings(scala2Only)
.settings(
name := "airframe-http-finagle",
description := "REST API binding for Finagle",
// Finagle doesn't support Scala 2.13 yet
libraryDependencies ++= Seq(
("com.twitter" %% "finagle-http" % FINAGLE_VERSION).cross(CrossVersion.for3Use2_13),
("com.twitter" %% "finagle-netty4-http" % FINAGLE_VERSION).cross(CrossVersion.for3Use2_13),
("com.twitter" %% "finagle-netty4" % FINAGLE_VERSION).cross(CrossVersion.for3Use2_13),
("com.twitter" %% "finagle-core" % FINAGLE_VERSION).cross(CrossVersion.for3Use2_13),
// Redirecting slf4j log in Finagle to airframe-log
"org.slf4j" % "slf4j-jdk14" % SLF4J_VERSION,
// Use a version that fixes [CVE-2017-18640]
"org.yaml" % "snakeyaml" % SNAKE_YAML_VERSION
)
)
.dependsOn(http.jvm)
lazy val okhttp =
project
.in(file("airframe-http-okhttp"))
.settings(buildSettings)
.settings(
name := "airframe-http-okhttp",
description := "REST API binding for OkHttp",
libraryDependencies ++= Seq(
"com.squareup.okhttp3" % "okhttp" % "4.12.0"
)
)
.dependsOn(http.jvm, netty % Test)
lazy val httpRecorder =
project
.in(file("airframe-http-recorder"))
.settings(buildSettings)
.settings(
name := "airframe-http-recorder",
description := "Http Response Recorder",
libraryDependencies ++= Seq(
)
)
.dependsOn(codec.jvm, metrics.jvm, control.jvm, netty, jdbc)
lazy val json =
crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("airframe-json"))
.settings(buildSettings)
.settings(
name := "airframe-json",
description := "JSON parser"
)
.jsSettings(jsBuildSettings)
.nativeSettings(nativeBuildSettings)
.dependsOn(log)
lazy val benchmark =
project
.in(file("airframe-benchmark"))
// Necessary for generating /META-INF/BenchmarkList
.enablePlugins(JmhPlugin, PackPlugin)
.settings(buildSettings)
.settings(noPublish)
.settings(
crossScalaVersions := targetScalaVersions,
name := "airframe-benchmark",
packMain := Map("airframe-benchmark" -> "wvlet.airframe.benchmark.BenchmarkMain"),
// Turbo mode didn't work with this error:
// java.lang.RuntimeException: ERROR: Unable to find the resource: /META-INF/BenchmarkList
turbo := false,
// Generate JMH benchmark cord before packaging and testing
Compile / pack := (Compile / pack).dependsOn(Test / compile).value,
Jmh / sourceDirectory := (Compile / sourceDirectory).value,
Jmh / compile := (Jmh / compile).triggeredBy(Compile / compile).value,
Test / compile := ((Test / compile).dependsOn(Jmh / compile)).value,
// Need to fork JVM so that sbt can set the classpass properly for running JMH
run / fork := true,
libraryDependencies ++= Seq(
"org.msgpack" % "msgpack-core" % MSGPACK_VERSION,
"org.openjdk.jmh" % "jmh-core" % JMH_VERSION,
"org.openjdk.jmh" % "jmh-generator-bytecode" % JMH_VERSION,
"org.openjdk.jmh" % "jmh-generator-reflection" % JMH_VERSION,
// Used only for json benchmark
"org.json4s" %% "json4s-jackson" % "4.0.7",
"io.circe" %% "circe-parser" % "0.14.10",
// For ScalaPB
// "com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion
// For grpc-java
"io.grpc" % "grpc-protobuf" % GRPC_VERSION,
"com.google.protobuf" % "protobuf-java" % "3.25.5",
("com.chatwork" %% "scala-ulid" % "1.0.24").cross(CrossVersion.for3Use2_13)
)
// Compile / PB.targets := Seq(
// scalapb.gen() -> (sourceManaged in Compile).value / "scalapb"
// ),
// publishing .tgz
// publishPackArchiveTgz
)
.dependsOn(msgpack.jvm, json.jvm, metrics.jvm, launcher, httpCodeGen, netty, grpc, ulid.jvm)
lazy val fluentd =
project
.in(file("airframe-fluentd"))
.settings(buildSettings)
.settings(
name := "airframe-fluentd",
description := "Fluentd logger",
libraryDependencies ++= Seq(
"org.komamitsu" % "fluency-core" % FLUENCY_VERSION,
"org.komamitsu" % "fluency-fluentd" % FLUENCY_VERSION,
"org.komamitsu" % "fluency-treasuredata" % FLUENCY_VERSION
// td-client-java -> json-simple happened to include junit 4.10 [CVE-2020-15250]
exclude ("junit", "junit"),
// Necessary for td-client-java, which is used in fluency-treasuredata
"com.fasterxml.jackson.datatype" % "jackson-datatype-json-org" % "2.18.1" % Provided,
"com.fasterxml.jackson.datatype" % "jackson-datatype-jdk8" % "2.18.1" % Provided,
// Redirecting slf4j log from Fluency to aiframe-log
"org.slf4j" % "slf4j-jdk14" % SLF4J_VERSION
)
)
.dependsOn(codec.jvm, di.jvm)
def sqlRefLib = { scalaVersion: String =>
if (scalaVersion.startsWith("2.13")) {
Seq(
// Include Spark just as a reference implementation
"org.apache.spark" %% "spark-sql" % "3.5.3" % Test,
// Include Trino as a reference implementation
"io.trino" % "trino-main" % "465" % Test
)
} else {
Seq.empty
}
}
lazy val parquet =