-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sbt
214 lines (198 loc) · 7.41 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
import com.typesafe.tools.mima.core._
Global / onChangedBuildSource := ReloadOnSourceChanges
val logger: Logger = ConsoleLogger()
lazy val ScalaVersions = new {
val V213 = "2.13.12"
val V212 = "2.12.18"
}
lazy val Versions = new {
val gpb3Version = "3.25.5"
val grpcVersion = "1.68.2"
val circeVersion = "0.14.10"
val http4sVersion = "0.22.2"
val akkaHttp = "10.2.10"
}
lazy val javaSettings = Seq(
crossPaths := false,
autoScalaLibrary := false
)
lazy val commonSettings = Seq(
organization := "com.avast.grpc",
homepage := Some(url("https://github.com/avast/grpc-json-bridge")),
licenses ++= Seq("MIT" -> url(s"https://github.com/avast/grpc-json-bridge/blob/${version.value}/LICENSE")),
developers := List(
Developer(
"jendakol",
"Jenda Kolena",
url("https://github.com/jendakol")
),
Developer(
"augi",
"Michal Augustýn",
url("https://github.com/augi")
),
Developer(
"sideeffffect",
"Ondra Pelech",
url("https://github.com/sideeffffect")
)
),
ThisBuild / turbo := true,
scalaVersion := ScalaVersions.V213,
crossScalaVersions := Seq(ScalaVersions.V212, ScalaVersions.V213),
scalacOptions --= {
if (!sys.env.contains("CI"))
List("-Xfatal-warnings") // to enable Scalafix
else
List()
},
description := "Library for exposing gRPC endpoints via HTTP API",
semanticdbEnabled := true, // enable SemanticDB
semanticdbVersion := scalafixSemanticdb.revision, // use Scalafix compatible version
ThisBuild / scalafixScalaBinaryVersion := CrossVersion.binaryScalaVersion(scalaVersion.value),
ThisBuild / scalafixDependencies ++= List(
"com.github.liancheng" %% "organize-imports" % "0.6.0",
"com.github.vovapolu" %% "scaluzzi" % "0.1.23"
),
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0",
"javax.annotation" % "javax.annotation-api" % "1.3.2",
"junit" % "junit" % "4.13.2" % Test,
"org.scalatest" %% "scalatest" % "3.2.17" % Test,
"com.github.sbt" % "junit-interface" % "0.13.3" % Test, // Required by sbt to execute JUnit tests
"ch.qos.logback" % "logback-classic" % "1.5.15" % Test
),
missinglinkExcludedDependencies ++= List(
moduleFilter(organization = "org.slf4j", name = "slf4j-api")
),
mimaPreviousArtifacts := previousStableVersion.value.map(organization.value %% moduleName.value % _).toSet,
testOptions += Tests.Argument(TestFrameworks.JUnit),
Test / tpolecatExcludeOptions += ScalacOptions.warnNonUnitStatement
) ++
addCommandAlias("check", "; lint; +missinglinkCheck; +mimaReportBinaryIssues; +test") ++
addCommandAlias(
"lint",
"; scalafmtSbtCheck; scalafmtCheckAll; compile:scalafix --check; test:scalafix --check"
) ++
addCommandAlias("fix", "; compile:scalafix; test:scalafix; scalafmtSbt; scalafmtAll")
lazy val grpcTestGenSettings = inConfig(Test)(sbtprotoc.ProtocPlugin.protobufConfigSettings) ++ Seq(
PB.protocVersion := "3.9.1",
grpcExePath := xsbti.api.SafeLazy.strict {
val exe: File = (baseDirectory in Test).value / ".bin" / grpcExeFileName
if (!exe.exists) {
logger.info("gRPC protoc plugin (for Java) does not exist. Downloading")
// IO.download(grpcExeUrl, exe)
IO.transfer(grpcExeUrl.openStream(), exe)
exe.setExecutable(true)
} else {
logger.debug("gRPC protoc plugin (for Java) exists")
}
exe
},
PB.protocOptions in Test ++= Seq(
s"--plugin=protoc-gen-java_rpc=${grpcExePath.value.get}",
s"--java_rpc_out=${(sourceManaged in Test).value.getAbsolutePath}"
),
PB.targets in Test := Seq(
PB.gens.java -> (sourceManaged in Test).value
)
)
lazy val grpcScalaPBTestGenSettings = inConfig(Test)(sbtprotoc.ProtocPlugin.protobufConfigSettings) ++ Seq(
PB.protocVersion := "3.9.1",
PB.targets in Test := Seq(
scalapb.gen() -> (sourceManaged in Test).value
)
)
lazy val root = project
.in(file("."))
.settings(commonSettings)
.settings(
name := "grpc-json-bridge",
publish / skip := true, // doesn't publish ivy XML files, in contrast to "publishArtifact := false"
mimaReportBinaryIssues := {}
)
.aggregate(core, http4s, akkaHttp, coreScalaPB)
lazy val core = (project in file("core")).settings(
commonSettings,
grpcTestGenSettings,
name := "grpc-json-bridge-core",
libraryDependencies ++= Seq(
"com.google.protobuf" % "protobuf-java" % Versions.gpb3Version,
"com.google.protobuf" % "protobuf-java-util" % Versions.gpb3Version,
"io.grpc" % "grpc-core" % Versions.grpcVersion,
"io.grpc" % "grpc-protobuf" % Versions.grpcVersion,
"io.grpc" % "grpc-stub" % Versions.grpcVersion,
"io.grpc" % "grpc-inprocess" % Versions.grpcVersion,
"org.typelevel" %% "cats-core" % "2.12.0",
"org.typelevel" %% "cats-effect" % "2.5.5",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
"org.slf4j" % "jul-to-slf4j" % "2.0.13",
"org.slf4j" % "jcl-over-slf4j" % "2.0.13",
"io.grpc" % "grpc-services" % Versions.grpcVersion % Test
)
)
lazy val coreScalaPB = (project in file("core-scalapb"))
.settings(
name := "grpc-json-bridge-core-scalapb",
commonSettings,
grpcScalaPBTestGenSettings,
libraryDependencies ++= Seq(
"com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion,
"com.thesamet.scalapb" %% "scalapb-json4s" % "0.12.1",
"junit" % "junit" % "4.13.2" % Test,
"org.scalatest" %% "scalatest" % "3.2.17" % Test,
"com.github.sbt" % "junit-interface" % "0.13.3" % Test, // Required by sbt to execute JUnit tests
"ch.qos.logback" % "logback-classic" % "1.5.15" % Test,
"io.grpc" % "grpc-services" % Versions.grpcVersion % Test,
"com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion % "protobuf"
)
)
.dependsOn(core)
lazy val http4s = (project in file("http4s"))
.settings(
commonSettings,
grpcTestGenSettings,
name := "grpc-json-bridge-http4s",
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-dsl" % Versions.http4sVersion,
"org.http4s" %% "http4s-blaze-server" % Versions.http4sVersion,
"org.http4s" %% "http4s-circe" % Versions.http4sVersion,
"io.circe" %% "circe-core" % Versions.circeVersion,
"io.circe" %% "circe-generic" % Versions.circeVersion
)
)
.dependsOn(core)
lazy val akkaHttp = (project in file("akka-http"))
.settings(
commonSettings,
grpcTestGenSettings,
name := "grpc-json-bridge-akkahttp",
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-http" % Versions.akkaHttp,
"com.typesafe.akka" %% "akka-http-spray-json" % Versions.akkaHttp,
"com.typesafe.akka" %% "akka-stream" % "2.6.20",
"com.typesafe.akka" %% "akka-testkit" % "2.6.20" % Test,
"com.typesafe.akka" %% "akka-http-testkit" % Versions.akkaHttp % Test
)
)
.dependsOn(core)
def grpcExeFileName: String = {
val os = if (scala.util.Properties.isMac) {
"osx-x86_64"
} else if (scala.util.Properties.isWin) {
"windows-x86_64"
} else {
"linux-x86_64"
}
s"$grpcArtifactId-${Versions.grpcVersion}-$os.exe"
}
val grpcArtifactId = "protoc-gen-grpc-java"
val grpcExeUrl = url(s"https://repo1.maven.org/maven2/io/grpc/$grpcArtifactId/${Versions.grpcVersion}/$grpcExeFileName")
val grpcExePath = SettingKey[xsbti.api.Lazy[File]]("grpcExePath")
addCommandAlias(
"ci",
"; check; +publishLocal"
)