-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
113 lines (98 loc) · 3.61 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
import com.github.sbt.git.SbtGit.GitKeys.gitCurrentBranch
enablePlugins(UniversalDeployPlugin, GitVersioning, sbtdocker.DockerPlugin)
git.useGitDescribe := true
git.baseVersion := "1.0.0"
git.uncommittedSignifier := Some("DIRTY")
inScope(Global)(
Seq(
onChangedBuildSource := ReloadOnSourceChanges,
scalaVersion := "2.13.15",
organization := "network.units",
organizationName := "Units Network",
resolvers ++= Resolver.sonatypeOssRepos("releases") ++ Resolver.sonatypeOssRepos("snapshots") ++ Seq(Resolver.mavenLocal),
scalacOptions ++= Seq(
"-Xsource:3",
"-feature",
"-deprecation",
"-unchecked",
"-language:higherKinds",
"-language:implicitConversions",
"-language:postfixOps",
"-Ywarn-unused:-implicits",
"-Xlint"
)
)
)
name := "consensus-client"
maintainer := "Units Network Team"
libraryDependencies ++= {
val node = "1.5-SNAPSHOT"
val sttp = "3.10.1"
Seq(
"com.wavesplatform" % "node-testkit" % node % Test,
"com.wavesplatform" % "node" % node % Provided,
"com.softwaremill.sttp.client3" % "core_2.13" % sttp,
"com.softwaremill.sttp.client3" %% "play-json" % sttp,
"com.github.jwt-scala" %% "jwt-play-json" % "10.0.1"
)
}
Compile / packageDoc / publishArtifact := false
def makeJarName(
org: String,
name: String,
revision: String,
artifactName: String,
artifactClassifier: Option[String]
): String =
org + "." +
name + "-" +
Option(artifactName.replace(name, "")).filterNot(_.isEmpty).map(_ + "-").getOrElse("") +
revision +
artifactClassifier.filterNot(_.isEmpty).map("-" + _).getOrElse("") +
".jar"
def getJarFullFilename(dep: Attributed[File]): String = {
val filename: Option[String] = for {
module <- dep.metadata.get(AttributeKey[ModuleID]("moduleID"))
artifact <- dep.metadata.get(AttributeKey[Artifact]("artifact"))
} yield makeJarName(module.organization, module.name, module.revision, artifact.name, artifact.classifier)
filename.getOrElse(dep.data.getName)
}
def universalDepMappings(deps: Seq[Attributed[File]]): Seq[(File, String)] =
for {
dep <- deps
} yield dep.data -> ("lib/" + getJarFullFilename(dep))
Universal / mappings += {
val jar = (Compile / packageBin).value
val id = projectID.value
val art = (Compile / packageBin / artifact).value
jar -> ("lib/" + makeJarName(id.organization, id.name, id.revision, art.name, art.classifier))
}
Universal / mappings ++= universalDepMappings((Runtime / dependencyClasspath).value.filterNot { p =>
p.get(AttributeKey[ModuleID]("moduleID")).exists { m =>
m.organization == "org.scala-lang" ||
m.organization.startsWith("com.fasterxml.jackson")
}
})
lazy val buildTarballsForDocker = taskKey[Unit]("Package consensus-client tarball and copy it to docker/target")
buildTarballsForDocker := {
IO.copyFile(
(Universal / packageZipTarball).value,
baseDirectory.value / "docker" / "target" / "consensus-client.tgz"
)
}
inTask(docker)(
Seq(
imageNames := Seq(
ImageName(s"consensus-client:${gitCurrentBranch.value}"), // Integration tests
ImageName("consensus-client:local") // local-network
),
dockerfile := NativeDockerfile(baseDirectory.value / "docker" / "Dockerfile"),
buildOptions := BuildOptions(cache = true)
)
)
docker := docker.dependsOn(LocalRootProject / buildTarballsForDocker).value
lazy val `consensus-client` = project.in(file("."))
lazy val `consensus-client-it` = project
.dependsOn(
`consensus-client` % "compile;test->test"
)