forked from rchain/rchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
426 lines (403 loc) · 13.1 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
import Dependencies._
import BNFC._
import Rholang._
import NativePackagerHelper._
import com.typesafe.sbt.packager.docker._
//allow stopping sbt tasks using ctrl+c without killing sbt itself
Global / cancelable := true
//disallow any unresolved version conflicts at all for faster feedback
Global / conflictManager := ConflictManager.strict
//resolve all version conflicts explicitly
Global / dependencyOverrides := Dependencies.overrides
lazy val projectSettings = Seq(
organization := "coop.rchain",
scalaVersion := "2.12.6",
version := "0.1.0-SNAPSHOT",
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots"),
"jitpack" at "https://jitpack.io"
),
scalafmtOnCompile := true,
testOptions in Test += Tests.Argument("-oD") //output test durations
)
lazy val coverageSettings = Seq(
coverageMinimum := 90,
coverageFailOnMinimum := false,
coverageExcludedFiles := Seq(
(javaSource in Compile).value,
(sourceManaged in Compile).value.getPath ++ "/.*"
).mkString(";")
)
lazy val compilerSettings = CompilerSettings.options ++ Seq(
crossScalaVersions := Seq("2.11.12", scalaVersion.value)
)
// Before starting sbt export YOURKIT_AGENT set to the profiling agent appropriate
// for your OS (https://www.yourkit.com/docs/java/help/agent.jsp)
lazy val profilerSettings = Seq(
javaOptions in run ++= sys.env
.get("YOURKIT_AGENT")
.map(agent => s"-agentpath:$agent=onexit=snapshot,sampling")
.toSeq,
javaOptions in reStart ++= (javaOptions in run).value
)
lazy val commonSettings = projectSettings ++ coverageSettings ++ compilerSettings ++ profilerSettings
lazy val shared = (project in file("shared"))
.settings(commonSettings: _*)
.settings(
version := "0.1",
libraryDependencies ++= commonDependencies ++ Seq(
catsCore,
catsEffect,
catsMtl,
monix,
scodecCore,
scodecBits,
scalapbRuntimegGrpc
)
)
lazy val casper = (project in file("casper"))
.settings(commonSettings: _*)
.settings(rholangSettings: _*)
.settings(
name := "casper",
libraryDependencies ++= commonDependencies ++ protobufLibDependencies ++ Seq(
catsCore,
catsMtl,
monix
),
rholangProtoBuildAssembly := (rholangProtoBuild / Compile / incrementalAssembly).value
)
.dependsOn(
blockStorage % "compile->compile;test->test",
comm % "compile->compile;test->test",
shared % "compile->compile;test->test",
crypto,
models,
rspace,
rholang,
rholangProtoBuild
)
lazy val comm = (project in file("comm"))
.settings(commonSettings: _*)
.settings(
version := "0.1",
libraryDependencies ++= commonDependencies ++ kamonDependencies ++ protobufDependencies ++ Seq(
grpcNetty,
nettyBoringSsl,
scalapbRuntimegGrpc,
scalaUri,
weupnp,
hasher,
catsCore,
catsMtl,
monix,
guava
),
PB.targets in Compile := Seq(
PB.gens.java -> (sourceManaged in Compile).value,
scalapb.gen(javaConversions = true) -> (sourceManaged in Compile).value,
grpcmonix.generators.GrpcMonixGenerator() -> (sourceManaged in Compile).value
)
)
.dependsOn(shared, crypto)
lazy val crypto = (project in file("crypto"))
.settings(commonSettings: _*)
.settings(
name := "crypto",
libraryDependencies ++= commonDependencies ++ protobufLibDependencies ++ Seq(
guava,
bouncyCastle,
scalacheckNoTest,
kalium,
jaxb,
secp256k1Java,
scodecBits
),
fork := true,
doctestTestFramework := DoctestTestFramework.ScalaTest
)
lazy val models = (project in file("models"))
.settings(commonSettings: _*)
.settings(
libraryDependencies ++= commonDependencies ++ protobufDependencies ++ Seq(
catsCore,
scalacheck,
scalacheckShapeless,
scalapbRuntimegGrpc
),
PB.targets in Compile := Seq(
scalapb.gen(flatPackage = true) -> (sourceManaged in Compile).value,
grpcmonix.generators
.GrpcMonixGenerator(flatPackage = true) -> (sourceManaged in Compile).value
)
)
.dependsOn(rspace)
lazy val node = (project in file("node"))
.settings(commonSettings: _*)
.enablePlugins(RpmPlugin, DebianPlugin, JavaAppPackaging, BuildInfoPlugin)
.settings(
version := "0.6.4",
name := "rnode",
maintainer := "Pyrofex, Inc. <[email protected]>",
packageSummary := "RChain Node",
packageDescription := "RChain Node - the RChain blockchain node server software.",
libraryDependencies ++=
apiServerDependencies ++ commonDependencies ++ kamonDependencies ++ protobufDependencies ++ Seq(
catsCore,
grpcNetty,
jline,
scallop,
scalaUri,
scalapbRuntimegGrpc,
tomlScala
),
PB.targets in Compile := Seq(
PB.gens.java -> (sourceManaged in Compile).value / "protobuf",
scalapb.gen(javaConversions = true) -> (sourceManaged in Compile).value / "protobuf",
grpcmonix.generators.GrpcMonixGenerator() -> (sourceManaged in Compile).value / "protobuf"
),
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion, git.gitHeadCommit),
buildInfoPackage := "coop.rchain.node",
mainClass in assembly := Some("coop.rchain.node.Main"),
assemblyMergeStrategy in assembly := {
case x if x.endsWith("io.netty.versions.properties") => MergeStrategy.first
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
},
/* Dockerization */
dockerUsername := Some(organization.value),
dockerUpdateLatest := true,
dockerBaseImage := "openjdk:8u171-jre-slim-stretch",
dockerCommands := {
val daemon = (daemonUser in Docker).value
Seq(
Cmd("FROM", dockerBaseImage.value),
ExecCmd("RUN", "apt", "update"),
ExecCmd("RUN", "apt", "install", "-yq", "openssl"),
Cmd("LABEL", s"""MAINTAINER="${maintainer.value}""""),
Cmd("WORKDIR", (defaultLinuxInstallLocation in Docker).value),
Cmd("ADD", s"--chown=$daemon:$daemon opt /opt"),
Cmd("USER", "root"),
ExecCmd("ENTRYPOINT", "bin/rnode", "--profile=docker"),
ExecCmd("CMD", "run")
)
},
mappings in Docker ++= {
val base = (defaultLinuxInstallLocation in Docker).value
directory((baseDirectory in rholang).value / "examples")
.map { case (f, p) => f -> s"$base/$p" }
},
/* Packaging */
linuxPackageMappings ++= {
val file = baseDirectory.value / "rnode.service"
val rholangExamples = directory((baseDirectory in rholang).value / "examples")
.map { case (f, p) => (f, s"/usr/share/rnode/$p") }
Seq(
packageMapping(file -> "/lib/systemd/system/rnode.service"),
packageMapping(rholangExamples: _*)
)
},
/* Debian */
debianPackageDependencies in Debian ++= Seq(
"openjdk-8-jre-headless (>= 1.8.0.171)",
"openssl(>= 1.0.2g) | openssl(>= 1.1.0f)", //ubuntu & debian
"bash (>= 2.05a-11)"
),
/* Redhat */
rpmVendor := "rchain.coop",
rpmUrl := Some("https://rchain.coop"),
rpmLicense := Some("Apache 2.0"),
packageArchitecture in Rpm := "noarch",
maintainerScripts in Rpm := maintainerScriptsAppendFromFile((maintainerScripts in Rpm).value)(
RpmConstants.Post -> (sourceDirectory.value / "rpm" / "scriptlets" / "post")
),
rpmPrerequisites := Seq(
"java-1.8.0-openjdk-headless >= 1.8.0.171",
//"openssl >= 1.0.2k | openssl >= 1.1.0h", //centos & fedora but requires rpm 4.13 for boolean
"openssl"
)
)
.dependsOn(casper, comm, crypto, rholang)
lazy val regex = (project in file("regex"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= commonDependencies)
lazy val rholang = (project in file("rholang"))
.settings(commonSettings: _*)
.settings(bnfcSettings: _*)
.settings(
name := "rholang",
scalacOptions ++= Seq(
"-language:existentials",
"-language:higherKinds",
"-Yno-adapted-args"
),
libraryDependencies ++= commonDependencies ++ Seq(
catsMtl,
catsEffect,
monix,
scallop,
lightningj
),
mainClass in assembly := Some("coop.rchain.rho2rose.Rholang2RosetteCompiler"),
coverageExcludedFiles := Seq(
(javaSource in Compile).value,
(bnfcGrammarDir in BNFCConfig).value,
(bnfcOutputDir in BNFCConfig).value,
baseDirectory.value / "src" / "main" / "k",
baseDirectory.value / "src" / "main" / "rbl"
).map(_.getPath ++ "/.*").mkString(";"),
fork in Test := true,
//constrain the resource usage so that we hit SOE-s and OOME-s more quickly should they happen
javaOptions in Test ++= Seq("-Xss240k", "-XX:MaxJavaStackTraceDepth=10000", "-Xmx128m")
)
.dependsOn(models % "compile->compile;test->test", rspace % "compile->compile;test->test", crypto)
lazy val rholangCLI = (project in file("rholang-cli"))
.settings(commonSettings: _*)
.settings(
mainClass in assembly := Some("coop.rchain.rholang.interpreter.RholangCLI")
)
.dependsOn(rholang)
lazy val rholangProtoBuildJar = Def.task(
(assemblyOutputPath in (assembly)).value
)
lazy val _incrementalAssembly = Def.taskDyn(
if (jarOutDated((rholangProtoBuildJar).value, (Compile / scalaSource).value))
(assembly)
else
rholangProtoBuildJar
)
lazy val incrementalAssembly = taskKey[File]("Only assemble if sources are newer than jar")
lazy val rholangProtoBuild = (project in file("rholang-proto-build"))
.settings(commonSettings: _*)
.settings(
name := "rholang-proto-build",
incrementalAssembly in Compile := _incrementalAssembly.value
)
.dependsOn(rholang)
lazy val roscalaMacros = (project in file("roscala/macros"))
.settings(commonSettings: _*)
.settings(
libraryDependencies ++= commonDependencies ++ Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value
)
)
lazy val roscala = (project in file("roscala"))
.settings(commonSettings: _*)
.settings(
name := "Rosette",
mainClass in assembly := Some("coop.rchain.rosette.Main"),
assemblyJarName in assembly := "rosette.jar",
inThisBuild(
List(addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full))
),
libraryDependencies ++= commonDependencies
)
.dependsOn(roscalaMacros)
lazy val blockStorage = (project in file("block-storage"))
.settings(commonSettings: _*)
.settings(
name := "block-storage",
version := "0.0.1-SNAPSHOT",
libraryDependencies ++= commonDependencies ++ protobufLibDependencies ++ Seq(
lmdbjava,
catsCore,
catsEffect,
catsMtl
)
)
.dependsOn(shared, models)
lazy val rspace = (project in file("rspace"))
.configs(IntegrationTest extend Test)
.enablePlugins(SiteScaladocPlugin, GhpagesPlugin, TutPlugin)
.settings(commonSettings: _*)
.settings(
scalacOptions ++= Seq(
"-Xfatal-warnings"
),
Defaults.itSettings,
name := "rspace",
version := "0.2.1-SNAPSHOT",
libraryDependencies ++= commonDependencies ++ kamonDependencies ++ Seq(
lmdbjava,
catsCore,
scodecCore,
scodecCats,
scodecBits,
guava
),
/* Tutorial */
tutTargetDirectory := (baseDirectory in Compile).value / ".." / "docs" / "rspace",
/* Publishing Settings */
scmInfo := Some(
ScmInfo(url("https://github.com/rchain/rchain"), "[email protected]:rchain/rchain.git")
),
git.remoteRepo := scmInfo.value.get.connection,
useGpg := true,
pomIncludeRepository := { _ =>
false
},
publishMavenStyle := true,
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
publishArtifact in Test := false,
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")),
homepage := Some(url("https://www.rchain.coop")),
developers := List(
Developer(
id = "guardbotmk3",
name = "Kyle Butt",
email = "[email protected]",
url = url("https://www.pyrofex.net")
),
Developer(
id = "ys-pyrofex",
name = "Yaraslau Levashkevich",
email = "[email protected]",
url = url("https://www.pyrofex.net")
),
Developer(
id = "KentShikama",
name = "Kent Shikama",
email = "[email protected]",
url = url("https://www.rchain.coop")
),
Developer(
id = "henrytill",
name = "Henry Till",
email = "[email protected]",
url = url("https://www.pyrofex.net")
)
)
)
.dependsOn(shared, crypto)
lazy val rspaceBench = (project in file("rspace-bench"))
.settings(
commonSettings,
libraryDependencies ++= commonDependencies
)
.enablePlugins(JmhPlugin)
.dependsOn(rspace, rholang)
lazy val rchain = (project in file("."))
.settings(commonSettings: _*)
.aggregate(
blockStorage,
casper,
comm,
crypto,
models,
node,
regex,
rholang,
rholangCLI,
roscala,
rspace,
rspaceBench,
shared
)