-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.sbt
More file actions
155 lines (133 loc) · 5.18 KB
/
build.sbt
File metadata and controls
155 lines (133 loc) · 5.18 KB
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
import com.github.sbt.git.SbtGit.GitKeys.gitCurrentBranch
import scala.sys.process.{Process, ProcessLogger}
enablePlugins(UniversalDeployPlugin, GitVersioning, VersionObject)
git.useGitDescribe := true
git.baseVersion := "1.4.0"
git.uncommittedSignifier := Some("DIRTY")
inScope(Global)(
Seq(
onChangedBuildSource := ReloadOnSourceChanges,
scalaVersion := "3.8.3",
organization := "network.units",
organizationName := "Units Network",
resolvers ++= Seq(Resolver.sonatypeCentralSnapshots, Resolver.mavenLocal),
scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-Wshadow:all",
"-Wunused:all",
"-explain-cyclic",
"-Wimplausible-patterns",
"-Wsafe-init",
"-language:higherKinds",
"-language:implicitConversions",
"-language:postfixOps"
)
)
)
name := "consensus-client"
maintainer := "Units Network Team"
def nettyModule(module: String): ModuleID = "io.netty" % s"netty-$module" % "4.2.12.Final"
// These overrides are needed so that there are no different versions of the same component on the classpath when the extension is installed
dependencyOverrides ++= Seq(
"org.playframework" %% "play-json" % "3.0.6",
"com.squareup.okhttp3" % "okhttp" % "4.12.0",
"com.squareup.okhttp3" % "logging-interceptor" % "4.12.0",
"com.squareup.okio" % "okio" % "3.6.0",
"com.squareup.okio" % "okio-jvm" % "3.17.0",
"org.apache.httpcomponents" % "httpclient" % "4.5.14",
"org.reactivestreams" % "reactive-streams" % "1.0.4",
"org.jetbrains.kotlin" % "kotlin-stdlib" % "2.1.21",
"org.jetbrains.kotlin" % "kotlin-stdlib-jdk7" % "1.8.21",
"org.jetbrains.kotlin" % "kotlin-stdlib-jdk8" % "1.8.21",
"org.bouncycastle" % "bcprov-jdk18on" % "1.83",
nettyModule("codec-http2"),
nettyModule("codec-http"),
nettyModule("handler-proxy"),
nettyModule("codec-socks"),
nettyModule("transport-native-unix-common"),
nettyModule("resolver-dns")
)
libraryDependencies ++= {
val node = "1.6.2-SNAPSHOT"
val sttpVersion = "3.11.0"
Seq(
"com.wavesplatform" % "node-testkit" % node % Test,
"com.wavesplatform" % "node" % node % Provided,
"com.softwaremill.sttp.client3" %% "core" % sttpVersion,
"com.softwaremill.sttp.client3" %% "play-json" % sttpVersion,
"com.github.jwt-scala" %% "jwt-play-json" % "11.0.4",
("org.web3j" % "core" % "4.13.0").excludeAll(
ExclusionRule("org.slf4j", "slf4j-api"),
ExclusionRule("org.bouncycastle", "bcprov-jdk15on")
)
)
}
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"
)
}
val docker = taskKey[Unit]("Build docker image for integration tests")
docker := {
val log = streams.value.log
val cwd = baseDirectory.value / "docker"
val cmd = Seq("docker", "build", "-t", "consensus-client:local", "-t", s"consensus-client:${gitCurrentBranch.value}", ".")
log.info(s"Running `${cmd.mkString(" ")}` from $cwd")
val processLogger = ProcessLogger(
(out: String) => log.info(out),
(err: String) => log.info(err) // Redirect STDERR to info
)
val exit = Process(cmd, cwd).!(processLogger)
if (exit != 0) sys.error(s"Docker build failed with exit code $exit")
}
docker := docker.dependsOn(LocalRootProject / buildTarballsForDocker).value
lazy val `consensus-client` = project
.in(file("."))
.settings(
Test / resources += baseDirectory.value / "contracts" / "waves" / "src" / "main.ride"
)
lazy val `consensus-client-it` = project
.dependsOn(
`consensus-client` % "compile;test->test"
)