-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
81 lines (66 loc) · 2.58 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
import sbt._
name := "fossildb"
def getVersionFromGit: String = {
def run(cmd: String): String = new java.io.BufferedReader(new java.io.InputStreamReader(java.lang.Runtime.getRuntime.exec(cmd).getInputStream)).readLine()
def getBranch = run("git rev-parse --abbrev-ref HEAD")
if (sys.env.contains("CI") && getBranch == "master") {
val oldVersion = run("git describe --tags --abbrev=0").split('.').toList.map(_.toInt)
(oldVersion.init :+ (oldVersion.last + 1)).mkString(".")
} else {
"DEV-" + getBranch
}
}
ThisBuild / scalacOptions ++= Seq(
"-feature",
"-deprecation"
)
version := getVersionFromGit
scalaVersion := "2.13.12"
libraryDependencies ++= Seq(
"ch.qos.logback" % "logback-classic" % "1.4.7",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
"org.scalatest" % "scalatest_2.13" % "3.2.15" % "test",
"io.grpc" % "grpc-netty" % scalapb.compiler.Version.grpcJavaVersion,
"io.grpc" % "grpc-services" % scalapb.compiler.Version.grpcJavaVersion,
"com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion,
"org.rocksdb" % "rocksdbjni" % "8.10.0",
"com.github.scopt" %% "scopt" % "4.1.0"
)
Compile / managedSourceDirectories += target.value / "protobuf-generated"
Compile / PB.targets := Seq(
scalapb.gen() -> (target.value / "protobuf-generated")
)
Compile / mainClass := Some("com.scalableminds.fossildb.FossilDB")
assembly / assemblyMergeStrategy := {
case x if x.endsWith("io.netty.versions.properties") => MergeStrategy.first
// compare https://stackoverflow.com/questions/54834125/sbt-assembly-deduplicate-module-info-class
case x if x.endsWith("module-info.class") => MergeStrategy.concat
case x =>
val oldStrategy = (assembly / assemblyMergeStrategy).value
oldStrategy(x)
}
assembly / assemblyJarName := "fossildb.jar"
lazy val buildInfoSettings = Seq(
buildInfoKeys := Seq[BuildInfoKey](version,
"commitHash" -> new java.lang.Object() {
override def toString: String = {
try {
val extracted = new java.io.InputStreamReader(java.lang.Runtime.getRuntime.exec("git rev-parse HEAD").getInputStream)
val str = new java.io.BufferedReader(extracted).readLine()
if (str == null) {
"get git hash failed"
} else str
} catch {
case t: Throwable => "get git hash failed"
}
}
}.toString()
),
buildInfoPackage := "fossildb",
buildInfoOptions := Seq(BuildInfoOption.BuildTime, BuildInfoOption.ToJson)
)
lazy val root = (project in file(".")).
enablePlugins(BuildInfoPlugin).
settings(
buildInfoSettings
)