-
Notifications
You must be signed in to change notification settings - Fork 14
/
build.sbt
133 lines (121 loc) · 4.25 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
import sbt.Keys.libraryDependencies
// Build shared info
ThisBuild / organization := "co.ledger"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / scalaVersion := "2.13.3"
ThisBuild / resolvers += Resolver.sonatypeRepo("releases")
ThisBuild / scalacOptions ++= CompilerFlags.all
ThisBuild / buildInfoPackage := "buildinfo"
ThisBuild / buildInfoKeys := Seq[BuildInfoKey](
name,
version,
scalaVersion,
sbtVersion,
git.gitHeadCommit
)
// Shared Plugins
enablePlugins(BuildInfoPlugin)
ThisBuild / libraryDependencies += compilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3")
lazy val ignoreFiles = List("application.conf.sample")
// Runtime
scalaVersion := "2.13.3"
scalacOptions ++= CompilerFlags.all
resolvers += Resolver.sonatypeRepo("releases")
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3")
lazy val assemblySettings = Seq(
test in assembly := {},
assemblyOutputPath in assembly := file(
target.value.getAbsolutePath
) / "assembly" / (name.value + "-" + version.value + ".jar"),
cleanFiles += file(target.value.getAbsolutePath) / "assembly",
// Remove resources files from the JAR (they will be copied to an external folder)
assemblyMergeStrategy in assembly := {
case PathList("META-INF", _) => MergeStrategy.discard
case PathList("BUILD") => MergeStrategy.discard
case path =>
if (ignoreFiles.contains(path))
MergeStrategy.discard
else
(assemblyMergeStrategy in assembly).value(path)
}
)
lazy val dockerSettings = Seq(
imageNames in docker := Seq(
// Sets the latest tag
ImageName(s"ledgerhq/${name.value}:latest"),
// Sets a name with a tag that contains the project version
ImageName(
namespace = Some("ledgerhq"),
repository = name.value,
tag = Some(version.value)
)
),
// User `docker` to build docker image
dockerfile in docker := {
// The assembly task generates a fat JAR file
val artifact: File = (assemblyOutputPath in assembly).value
val artifactTargetPath = s"/app/${(assemblyOutputPath in assembly).value.name}"
new Dockerfile {
from("openjdk:14.0.2")
copy(artifact, artifactTargetPath)
entryPoint("java", "-jar", artifactTargetPath)
}
}
)
lazy val sharedSettings = assemblySettings ++ dockerSettings ++ Defaults.itSettings
// Common lama library
lazy val common = (project in file("common"))
.settings(
name := "lama-common",
libraryDependencies ++= Dependencies.lamaCommon
)
lazy val accountManager = (project in file("account-manager"))
.enablePlugins(Fs2Grpc, FlywayPlugin, sbtdocker.DockerPlugin)
.configs(IntegrationTest)
.settings(
name := "lama-account-manager",
sharedSettings,
// Dependencies
libraryDependencies ++= (Dependencies.accountManager ++ Dependencies.test),
// Proto config
scalapbCodeGeneratorOptions += CodeGeneratorOption.FlatPackage,
// Flyway credentials to migrate sql scripts
flywayLocations += "db/migration",
flywayUrl := "jdbc:postgresql://localhost:5432/lama",
flywayUser := "lama",
flywayPassword := "serge"
)
.dependsOn(common)
lazy val btcWorker = (project in file("coins/bitcoin/worker"))
.enablePlugins(sbtdocker.DockerPlugin)
.configs(IntegrationTest)
.settings(
name := "lama-bitcoin-worker",
sharedSettings,
libraryDependencies ++= (Dependencies.btcWorker ++ Dependencies.test)
)
.dependsOn(common)
lazy val btcInterpreter = (project in file("coins/bitcoin/interpreter"))
.enablePlugins(Fs2Grpc, FlywayPlugin, sbtdocker.DockerPlugin)
.configs(IntegrationTest)
.settings(
name := "lama-bitcoin-interpreter",
sharedSettings,
libraryDependencies ++= (Dependencies.btcInterpreter ++ Dependencies.test),
// Proto config
scalapbCodeGeneratorOptions += CodeGeneratorOption.FlatPackage,
// Flyway credentials to migrate sql scripts
flywayLocations += "db",
flywayUrl := "jdbc:postgresql://localhost:5432/lama-btc-interpreter",
flywayUser := "lama",
flywayPassword := "serge"
)
.dependsOn(common)
lazy val btcService = (project in file("coins/bitcoin/service"))
.enablePlugins(Fs2Grpc, sbtdocker.DockerPlugin)
.settings(
name := "lama-bitcoin-service",
libraryDependencies ++= Dependencies.btcService,
sharedSettings
)
.dependsOn(common)