-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
270 lines (260 loc) · 10.8 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
import sbt.*
import sbt.Keys.*
import sbtassembly.AssemblyPlugin.autoImport.*
import sbtbuildinfo.BuildInfoPlugin
import sbtbuildinfo.BuildInfoPlugin.autoImport.*
import sbtghpackages.GitHubPackagesPlugin.autoImport.*
import sbtprotoc.ProtocPlugin.autoImport.PB
inThisBuild(
Seq(
organization := "io.iohk.atala",
scalaVersion := "2.13.15",
fork := true,
run / connectInput := true,
versionScheme := Some("semver-spec"),
githubOwner := "input-output-hk",
githubRepository := "atala-prism"
)
)
lazy val versions = new {
val bouncycastle = "1.70"
val catsScalatest = "3.1.1"
val chimney = "0.6.1"
val circe = "0.14.1"
val circeOptics = "0.14.1"
val diffx = "0.7.0"
val doobie = "1.0.0-RC2"
val enumeratum = "1.7.0"
val enumeratumDoobie = "1.7.1"
val flyway = "8.5.4"
val grpc = "1.45.0"
val kamon = "2.4.8"
val logback = "1.2.11"
val logbackLogstash = "7.0.1"
val jaxb = "2.3.1"
val mockito = "1.17.5"
val playJson = "2.9.1"
val postgresql = "42.3.3"
val scalatest = "3.2.11"
val scalatestplus = s"$scalatest.0"
val scalapb = "0.11.6"
val sttp = "3.5.1"
val slf4j = "1.7.36"
val tofu = "0.12.0.1"
val tofuDerevo = "0.13.0"
val twirl = "1.5.1"
val typesafeConfig = "1.4.2"
val fs2 = "3.8.0"
val scalaUri = "4.0.0"
val testContainers = "0.41.4"
}
lazy val Dependencies = new {
val bouncyBcpkix =
"org.bouncycastle" % "bcpkix-jdk15on" % versions.bouncycastle
val bouncyBcprov =
"org.bouncycastle" % "bcprov-jdk15on" % versions.bouncycastle
val chimney = "io.scalaland" %% "chimney" % versions.chimney
val circeCore = "io.circe" %% "circe-core" % versions.circe
val circeGeneric = "io.circe" %% "circe-generic" % versions.circe
val circeGenericExtras = "io.circe" %% "circe-generic-extras" % versions.circe
val circeParser = "io.circe" %% "circe-parser" % versions.circe
val circeOptics = "io.circe" %% "circe-optics" % versions.circeOptics
val doobieCore = "org.tpolecat" %% "doobie-core" % versions.doobie
val doobiePostgresCirce =
"org.tpolecat" %% "doobie-postgres-circe" % versions.doobie
val doobieHikari = "org.tpolecat" %% "doobie-hikari" % versions.doobie
val enumeratum = "com.beachape" %% "enumeratum" % versions.enumeratum
val enumeratumCirce =
"com.beachape" %% "enumeratum-circe" % versions.enumeratum
val enumeratumDoobie =
"com.beachape" %% "enumeratum-doobie" % versions.enumeratumDoobie
val flyway = "org.flywaydb" % "flyway-core" % versions.flyway
val grpcNetty = "io.grpc" % "grpc-netty" % versions.grpc
val grpcServices = "io.grpc" % "grpc-services" % versions.grpc
val grpcContext = "io.grpc" % "grpc-context" % versions.grpc
val kamonBundle = "io.kamon" %% "kamon-bundle" % versions.kamon
val kamonPrometheus = "io.kamon" %% "kamon-prometheus" % versions.kamon
val logbackCore = "ch.qos.logback" % "logback-core" % versions.logback
val logbackClassic = "ch.qos.logback" % "logback-classic" % versions.logback
val logbackLogstash =
"net.logstash.logback" % "logstash-logback-encoder" % versions.logbackLogstash
val jaxb = "javax.xml.bind" % "jaxb-api" % versions.jaxb
val playJson = "com.typesafe.play" %% "play-json" % versions.playJson
val postgresql = "org.postgresql" % "postgresql" % versions.postgresql
val scalapbRuntimeGrpc =
"com.thesamet.scalapb" %% "scalapb-runtime-grpc" % versions.scalapb
val slf4j = "org.slf4j" % "slf4j-api" % versions.slf4j
val sttpCore = "com.softwaremill.sttp.client3" %% "core" % versions.sttp
val sttpCE2 =
"com.softwaremill.sttp.client3" %% "async-http-client-backend-cats" % versions.sttp
val tofu =
"tf.tofu" %% "tofu-core-ce3" % versions.tofu
val tofuLogging = "tf.tofu" %% "tofu-logging" % versions.tofu
val tofuDerevoTagless =
"tf.tofu" %% "derevo-cats-tagless" % versions.tofuDerevo
val twirlApi = "com.typesafe.play" %% "twirl-api" % versions.twirl
val typesafeConfig = "com.typesafe" % "config" % versions.typesafeConfig
val fs2 = "co.fs2" %% "fs2-io" % versions.fs2
val scalaUri = "io.lemonlabs" %% "scala-uri" % versions.scalaUri
// Test dependencies
val catsScalatest =
"com.ironcorelabs" %% "cats-scalatest" % versions.catsScalatest % Test
val diffx =
"com.softwaremill.diffx" %% "diffx-scalatest-must" % versions.diffx % Test
val doobieScalatest =
"org.tpolecat" %% "doobie-scalatest" % versions.doobie % Test
val mockito = "org.mockito" %% "mockito-scala" % versions.mockito % Test
val mockitoScalatest =
"org.mockito" %% "mockito-scala-scalatest" % versions.mockito % Test
val scalatest = "org.scalatest" %% "scalatest" % versions.scalatest % Test
val scalatestWordspec =
"org.scalatest" %% "scalatest-wordspec" % versions.scalatest % Test
val scalatestplus =
"org.scalatestplus" %% "scalacheck-1-15" % versions.scalatestplus % Test
val testContainersScalaTest =
"com.dimafeng" %% "testcontainers-scala-scalatest" % versions.testContainers % Test
val testContainersPSQL =
"com.dimafeng" %% "testcontainers-scala-postgresql" % versions.testContainers % Test
val bouncyDependencies = Seq(bouncyBcpkix, bouncyBcprov)
val circeDependencies =
Seq(circeCore, circeGeneric, circeGenericExtras, circeParser, circeOptics)
val dockerDependencies =
Seq(testContainersScalaTest, testContainersPSQL)
val doobieDependencies =
Seq(doobieCore, doobiePostgresCirce, doobieHikari, doobieScalatest)
val enumeratumDependencies =
Seq(enumeratum, enumeratumCirce, enumeratumDoobie)
val grpcDependencies = Seq(grpcNetty, grpcServices, grpcContext)
val kamonDependencies = Seq(kamonBundle, kamonPrometheus)
val logbackDependencies =
Seq(logbackCore, logbackClassic, logbackLogstash, jaxb)
val mockitoDependencies = Seq(mockito, mockitoScalatest)
val scalatestDependencies =
Seq(scalatest, scalatestWordspec, scalatestplus, catsScalatest)
val sttpDependencies = Seq(sttpCore, sttpCE2)
val tofuDependencies = Seq(tofu, tofuLogging, tofuDerevoTagless)
val scalapbDependencies = Seq(
"com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion % "protobuf",
"com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion
)
}
publish / skip := true
lazy val root =
project
.in(file("."))
.settings(
name := "node",
Compile / mainClass := Some("io.iohk.atala.prism.node.NodeApp"),
buildInfoPackage := "io.iohk.atala.prism",
scalacOptions ~= (options =>
options.filterNot(
Set(
"-Xlint:package-object-classes",
"-Wdead-code",
"-Ywarn-dead-code"
)
)
),
scalacOptions += "-Ymacro-annotations",
javacOptions ++= Seq("-source", "1.11", "-target", "1.11"),
githubTokenSource := TokenSource.Environment("GITHUB_TOKEN"),
addCompilerPlugin(
"org.typelevel" % "kind-projector" % "0.13.3" cross CrossVersion.full
),
Test / fork := true,
Test / parallelExecution := false,
Test / testForkedParallel := false,
assembly / test := {},
commands += Command.args("testOnlyUntilFailed", "<testOnly params>") { (state, args) =>
val argsString = args.mkString(" ")
("testOnly " + argsString) :: ("testOnlyUntilFailed " + argsString) :: state
},
assembly / assemblyExcludedJars := {
val cp = (assembly / fullClasspath).value
val excludeLibs =
Set(
"protobuf-javalite",
"kotlinx-coroutines-core",
"pbandk-protos",
"jakarta"
)
cp.filter { path =>
excludeLibs.exists(lib => path.data.getName.startsWith(lib))
}
},
assembly / assemblyMergeStrategy := {
// Merge service files, otherwise GRPC client doesn't work: https://github.com/grpc/grpc-java/issues/5493
case PathList("META-INF", "services", _*) => MergeStrategy.concat
case PathList("META-INF", "io.netty.versions.properties") =>
MergeStrategy.concat
// It is safe to discard when building an uber-jar according to https://stackoverflow.com/a/55557287
case x if x.endsWith("module-info.class") => MergeStrategy.discard
case "logback.xml" => MergeStrategy.first
case "scala-collection-compat.properties" => MergeStrategy.last
// org.bitcoin classes are coming from both bitcoinj and fr.acinq.secp256k1-jni
case PathList("org", "bitcoin", _*) => MergeStrategy.last
case x =>
val oldStrategy = (assembly / assemblyMergeStrategy).value
oldStrategy(x)
},
// Make ScalaPB compile protos relative to `protobuf_external_src/protos` directory.
// Otherwise, it will assume that `protobuf_external_src` is the root directory for proto files.
Compile / PB.protoSources := (Compile / PB.protoSources).value.map {
case externalSrc if externalSrc.toPath.endsWith("protobuf_external_src") =>
externalSrc / "proto"
case other => other
},
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "proto"
),
resolvers += Resolver.mavenLocal,
resolvers += Resolver.jcenterRepo,
resolvers += Resolver.mavenCentral,
Docker / maintainer := "[email protected]",
Docker / dockerUsername := Some("input-output-hk"),
Docker / dockerRepository := Some("ghcr.io"),
Docker / packageName := "prism-node",
dockerExposedPorts := Seq(5432),
dockerBaseImage := "openjdk:11",
libraryDependencies
++= Dependencies.circeDependencies
++ Dependencies.tofuDependencies
++ Dependencies.kamonDependencies
++ Dependencies.dockerDependencies
++ Dependencies.bouncyDependencies
++ Dependencies.enumeratumDependencies
++ Dependencies.doobieDependencies
++ Dependencies.grpcDependencies
++ Dependencies.logbackDependencies
++ Dependencies.sttpDependencies
++ Dependencies.mockitoDependencies
++ Dependencies.scalapbDependencies
++ Dependencies.scalatestDependencies
++ Seq(
Dependencies.chimney,
Dependencies.diffx,
Dependencies.flyway,
Dependencies.typesafeConfig,
Dependencies.postgresql,
Dependencies.scalapbRuntimeGrpc,
Dependencies.slf4j,
Dependencies.typesafeConfig,
Dependencies.fs2,
Dependencies.scalaUri
)
)
.enablePlugins(BuildInfoPlugin, JavaAppPackaging, DockerPlugin)
Global / onChangedBuildSource := ReloadOnSourceChanges
// ############################
// #### Release process #####
// ############################
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations.*
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
ReleaseStep(releaseStepTask(root / Docker / stage)),
setNextVersion
)