forked from virtualeconomy/v-systems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
174 lines (150 loc) · 5.28 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
import com.typesafe.sbt.packager.archetypes.TemplateWriter
import sbt.Keys._
import sbt._
import sbtcrossproject.CrossPlugin.autoImport.crossProject
enablePlugins(sbtdocker.DockerPlugin, JavaServerAppPackaging, JDebPackaging, SystemdPlugin)
name := "vsys"
organization := "systems.v"
version := "0.3.2"
scalaVersion in ThisBuild := "2.12.6"
crossPaths := false
publishArtifact in (Compile, packageDoc) := false
publishArtifact in (Compile, packageSrc) := false
mainClass in Compile := Some("vsys.Application")
scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-Ywarn-unused:-implicits",
"-Xlint")
logBuffered := false
fork in run := true
Test / fork := true
//assembly settings
assemblyJarName in assembly := s"vsys-all-${version.value}.jar"
assemblyMergeStrategy in assembly := {
case PathList("META-INF", "io.netty.versions.properties") => MergeStrategy.concat
case other => (assemblyMergeStrategy in assembly).value(other)
}
test in assembly := {}
coverageExcludedPackages := "com.wavesplatform.*;"
libraryDependencies ++=
Dependencies.network ++
Dependencies.db ++
Dependencies.http ++
Dependencies.akka ++
Dependencies.serialization ++
Dependencies.testKit ++
Dependencies.itKit ++
Dependencies.logging ++
Dependencies.matcher ++
Dependencies.kamon ++
Seq(
"com.iheart" %% "ficus" % "1.4.3",
("org.scorexfoundation" %% "scrypto" % "1.2.2")
.exclude("org.slf4j", "slf4j-api"),
"commons-net" % "commons-net" % "3.+",
"org.typelevel" %% "cats-core" % "1.0.0-RC1",
"io.monix" %% "monix" % "3.0.0-M2"
)
dependencyOverrides ++= Seq(
"com.google.guava" % "guava" % "21.0",
"com.typesafe.akka" % "akka-actor_2.12" % "2.5.14"
)
sourceGenerators in Compile += Def.task {
val versionFile = (sourceManaged in Compile).value / "vsys" / "Version.scala"
val versionExtractor = """(\d+)\.(\d+)\.(\d+).*""".r
val versionExtractor(major, minor, bugfix) = version.value
IO.write(versionFile,
s"""package vsys
|
|object Version {
| val VersionString = "${version.value}"
| val VersionTuple = ($major, $minor, $bugfix)
|}
|""".stripMargin)
Seq(versionFile)
}
inConfig(Test)(Seq(
logBuffered := false,
parallelExecution := false,
testOptions += Tests.Argument("-oIDOF", "-u", "target/test-reports")
))
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)
Defaults.itSettings
configs(IntegrationTest)
inConfig(IntegrationTest)(Seq(
parallelExecution := false,
test := (test dependsOn docker).value,
testOptions += Tests.Filter(_.endsWith("Suite"))
))
dockerfile in docker := {
val configTemplate = (resourceDirectory in IntegrationTest).value / "template.conf"
val startVsys = (sourceDirectory in IntegrationTest).value / "container" / "start-vsys.sh"
new Dockerfile {
from("anapsix/alpine-java:8_server-jre")
add(assembly.value, "/opt/vsys/vsys.jar")
add(Seq(configTemplate, startVsys), "/opt/vsys/")
run("chmod", "+x", "/opt/vsys/start-vsys.sh")
entryPoint("/opt/vsys/start-vsys.sh")
}
}
// packaging settings
val upstartScript = TaskKey[File]("upstartScript")
val packageSource = SettingKey[File]("packageSource")
val network = SettingKey[Network]("network")
commands += Command.command("packageAll") { state =>
"clean" ::
"assembly" ::
"debian:packageBin" ::
state
}
inConfig(Linux)(Seq(
maintainer := "v.systems",
packageSummary := "VSYS full node",
packageDescription := "VSYS full node"
))
network := Network(sys.props.get("network"))
normalizedName := "vsys"
javaOptions in Universal ++= Seq(
// -J prefix is required by the bash script
"-J-server",
// JVM memory tuning for 2g ram
"-J-Xms128m",
"-J-Xmx2g",
// from https://groups.google.com/d/msg/akka-user/9s4Yl7aEz3E/zfxmdc0cGQAJ
"-J-XX:+UseG1GC",
"-J-XX:+UseNUMA",
"-J-XX:+AlwaysPreTouch",
// probably can't use these with jstack and others tools
"-J-XX:+PerfDisableSharedMem",
"-J-XX:+ParallelRefProcEnabled",
"-J-XX:+UseStringDeduplication")
mappings in Universal += (baseDirectory.value / s"vsys-${network.value}.conf" -> "doc/vsys.conf.sample")
packageSource := sourceDirectory.value / "package"
upstartScript := {
val src = packageSource.value / "upstart.conf"
val dest = (target in Debian).value / "upstart" / s"${packageName.value}.conf"
val result = TemplateWriter.generateScript(src.toURI.toURL, linuxScriptReplacements.value)
IO.write(dest, result)
dest
}
linuxPackageMappings ++= Seq(
packageMapping((upstartScript.value, s"/usr/share/${packageName.value}/conf/upstart.conf"))
).map(_.withConfig().withPerms("644").withUser(packageName.value).withGroup(packageName.value))
linuxStartScriptTemplate in Debian := (packageSource.value / "systemd.service").toURI.toURL
linuxScriptReplacements += "detect-loader" ->
"""is_systemd() {
| which systemctl >/dev/null 2>&1 && \
| systemctl | grep -- -\.mount >/dev/null 2>&1
|}
|is_upstart() {
| /sbin/init --version | grep upstart >/dev/null 2>&1
|}
|""".stripMargin
inConfig(Debian)(Seq(
debianPackageDependencies += "java8-runtime-headless",
serviceAutostart := false,
maintainerScripts := maintainerScriptsFromDirectory(packageSource.value / "debian", Seq("preinst", "postinst", "postrm", "prerm"))
))
lazy val node = project.in(file("."))
lazy val generator = project.in(file("generator")).dependsOn(node % "compile->it")