-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
136 lines (126 loc) · 4.76 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
import Dependencies.*
import sbt.Keys.parallelExecution
Global / onChangedBuildSource := ReloadOnSourceChanges
inThisBuild(
List(
organization := "dev.faustin0",
developers := List(
Developer("faustin0", "Fausto Di Natale", "", url("https://github.com/faustin0")),
Developer("azanin", "Alessandro Zanin", "[email protected]", url("https://github.com/azanin"))
),
homepage := Some(url("https://github.com/faustin0/bus-info")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
pomIncludeRepository := { _ => false },
version := "0.2.2"
)
)
// General Settings
lazy val commonSettings = Seq(
scalaVersion := "2.13.12",
scalacOptions ++= Seq("-encoding", "utf8"),
addCompilerPlugin("org.typelevel" %% "kind-projector" % kindProjectorV cross CrossVersion.full),
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % betterMonadicForV),
libraryDependencies ++= dependencies ++ testDependencies
)
lazy val root = (project in file("."))
.aggregate(core, api, importer, tests)
.settings(name := "bus-info")
.settings(
update / aggregate := false
)
lazy val core = project
.in(file("modules/core"))
.settings(commonSettings)
.settings(
name := "core",
Test / parallelExecution := false,
Test / fork := true,
libraryDependencies ++= http4sClient ++ dynamoDeps :+ http4sXML
)
lazy val lambda_runtime = project
.in(file("modules/lambda-custom-runtime"))
.settings(commonSettings)
.settings(
name := "lambda-custom-runtime",
Test / parallelExecution := false,
Test / fork := false,
libraryDependencies ++= http4sClient :+ munit
)
lazy val api = project
.in(file("modules/api"))
.enablePlugins(BuildInfoPlugin, GraalVMNativeImagePlugin)
.dependsOn(core, lambda_runtime)
.settings(commonSettings)
.settings(
name := "api",
Test / parallelExecution := false,
Test / fork := true,
libraryDependencies ++= (httpServerDeps ++ awsLambdaDeps :+ lambdaRuntimeDeps),
Compile / mainClass := Some("dev.faustin0.api.Entrypoint"),
buildInfoKeys := Seq[BuildInfoKey](version),
buildInfoPackage := "dev.faustin0.info",
topLevelDirectory := None,
graalVMNativeImageOptions := Seq(
"--static",
"--libc=musl",
"--verbose",
"--no-fallback",
"-march=x86-64-v2", // https://docs.aws.amazon.com/linux/al2023/ug/performance-optimizations.html
"--strict-image-heap",
"--report-unsupported-elements-at-runtime",
"--initialize-at-build-time",
"--initialize-at-run-time=scala.util.Random",
"--initialize-at-run-time=org.http4s.multipart.Boundary$", // todo open PR on tapir?
"--initialize-at-run-time=software.amazon.awssdk.core.retry.backoff.FullJitterBackoffStrategy",
"--initialize-at-run-time=software.amazon.awssdk.services.dynamodb.DynamoDbRetryPolicy",
"--enable-http",
"--enable-https",
"--enable-all-security-services",
"--enable-url-protocols=https,http",
"--enable-url-protocols=http",
// "-H:+StaticExecutableWithDynamicLibC", // avoid http4s segmentation fault, an alternative to --libc=musl
"-H:+ReportExceptionStackTraces",
"-J-Dfile.encoding=UTF-8"
// "-Dcats.effect.tracing.mode=full",
// "-Dcats.effect.tracing.buffer.size=1024"
) ++ optimizationLevel(),
excludeDependencies ++= Seq(
// commons-logging is replaced by jcl-over-slf4j
ExclusionRule(organization = "commons-logging", name = "commons-logging"),
ExclusionRule(organization = "software.amazon.awssdk", name = "netty-nio-client"),
ExclusionRule(organization = "software.amazon.awssdk", name = "apache-client")
)
)
lazy val importer = project
.in(file("modules/importer"))
.enablePlugins(BuildInfoPlugin, JavaAppPackaging)
.dependsOn(core)
.settings(commonSettings)
.settings(
name := "importer",
Test / parallelExecution := false,
Test / fork := true,
libraryDependencies ++= awsDeps,
topLevelDirectory := None
)
lazy val tests = project
.in(file("modules/tests"))
.dependsOn(core, importer, api)
.configs(IntegrationTest)
.settings(commonSettings)
.settings(Defaults.itSettings)
.settings(
name := "tests",
Test / parallelExecution := false,
Test / fork := true,
IntegrationTest / fork := true,
libraryDependencies ++= awsDeps
)
def optimizationLevel(): Seq[String] =
sys.env
.get("OPTIMIZE_NATIVE")
.collect {
case "true" => "-O2"
case "false" => "-Ob"
}
.toSeq