-
Notifications
You must be signed in to change notification settings - Fork 43
/
build.sbt
318 lines (289 loc) · 10.3 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
def isGithubActions = sys.env.getOrElse("CI", "false") == "true"
def releaseVersion = sys.env.getOrElse("RELEASE_VERSION", "")
def isRelease = releaseVersion != ""
def githubRunNumber = sys.env.getOrElse("GITHUB_RUN_NUMBER", "")
def ossrhUsername = sys.env.getOrElse("OSSRH_USERNAME", "")
def ossrhPassword = sys.env.getOrElse("OSSRH_PASSWORD", "")
def publishVersion = if (isRelease) releaseVersion else if (isGithubActions) "2.9.0." + githubRunNumber + "-SNAPSHOT" else "0.0.0-LOCAL"
val org = "com.clever-cloud.pulsar4s"
val AkkaStreamVersion = "2.6.20" // compatible with Akka 2.5.x and 2.6.x
val CatsEffectVersion = "3.5.4"
val CirceVersion = "0.14.6"
val CommonsIoVersion = "2.4"
val ExtsVersion = "1.61.1"
val JacksonVersion = "2.17.2"
val Log4jVersion = "2.23.1"
val MonixVersion = "3.4.1"
val PekkoStreamVersion = "1.0.2"
val PlayJsonVersion = "2.10.6"
val PulsarVersion = "3.3.1"
val ReactiveStreamsVersion = "1.0.2"
val FunctionalStreamsVersion = "3.10.2"
val Json4sVersion = "4.0.7"
// Version of Avro4s for Scala 2.X
val Avro4sVersionFor2 = "4.1.2"
// Version of Avro4s for Scala 3.X
val Avro4sVersionFor3 = "5.0.13"
val ScalaVersion = "3.3.3"
val ScalatestVersion = "3.2.19"
val ScalazVersion = "7.2.36"
val Slf4jVersion = "2.0.16"
val SprayJsonVersion = "1.3.6"
val ZIOVersion = "2.0.22"
val ZIOInteropCatsVersion = "23.1.0.3"
lazy val commonScalaVersionSettings = Seq(
scalaVersion := ScalaVersion,
crossScalaVersions := Seq("2.12.19", "2.13.14", ScalaVersion)
)
lazy val warnUnusedImport = Seq(
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Seq()
case _ => Seq("-Ywarn-unused:imports")
}),
Compile / console / scalacOptions ~= {
_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports"))
},
Test / console / scalacOptions := (Compile / console / scalacOptions).value,
)
lazy val commonSettings = Seq(
organization := "com.clever-cloud.pulsar4s",
version := publishVersion,
resolvers ++= Seq(Resolver.mavenLocal),
Test / parallelExecution := false,
Global / parallelExecution := false,
Global / concurrentRestrictions += Tags.limit(Tags.Test, 1),
Compile / doc / scalacOptions := (Compile / doc / scalacOptions).value.filter(_ != "-Xfatal-warnings"),
scalacOptions ++= Seq("-unchecked", "-encoding", "utf8")
++ (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) => Seq(
"-deprecation",
)
case _ => Seq()
})
)
lazy val publishSettings = Seq(
publishMavenStyle := true,
Test / publishArtifact := false,
pomIncludeRepository := Function.const(false),
credentials += Credentials(
"Sonatype Nexus Repository Manager",
"s01.oss.sonatype.org",
ossrhUsername,
ossrhPassword
),
publishTo := {
val nexus = "https://s01.oss.sonatype.org/"
if (isRelease)
Some("releases" at nexus + "service/local/staging/deploy/maven2")
else
Some("snapshots" at nexus + "content/repositories/snapshots")
}
)
lazy val commonJvmSettings = Seq(
Test / testOptions += {
val flag = if (isGithubActions) "-oCI" else "-oDF"
Tests.Argument(TestFrameworks.ScalaTest, flag)
},
Test / fork := true,
Test / javaOptions := Seq("-Xmx3G"),
javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
javaOptions ++= Seq("-Xms512M", "-Xmx2048M", "-XX:MaxPermSize=2048M", "-XX:+CMSClassUnloadingEnabled"),
)
lazy val commonDeps = Seq(
libraryDependencies ++= Seq(
"com.sksamuel.exts" %% "exts" % ExtsVersion cross CrossVersion.for3Use2_13,
"org.slf4j" % "slf4j-api" % Slf4jVersion,
"org.scalatest" %% "scalatest" % ScalatestVersion % "test",
"org.apache.logging.log4j" % "log4j-api" % Log4jVersion % "test",
"org.apache.logging.log4j" % "log4j-slf4j-impl" % Log4jVersion % "test"
)
)
lazy val pomSettings = Seq(
homepage := Some(url("https://github.com/CleverCloud/pulsar4s")),
licenses := Seq("Apache 2" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
scmInfo := Some(ScmInfo(url("https://github.com/CleverCloud/pulsar4s"), "scm:git:git@github.com:CleverCloud/pulsar4s.git")),
apiURL := Some(url("http://github.com/CleverCloud/pulsar4s/")),
pomExtra := <developers>
<developer>
<id>sksamuel</id>
<name>Sam Samuel</name>
<url>https://github.com/sksamuel</url>
</developer>
<developer>
<id>judu</id>
<name>Julien Durillon</name>
<url>https://github.com/judu</url>
</developer>
</developers>
)
val travisCreds = Credentials(
"Sonatype Nexus Repository Manager",
"s01.oss.sonatype.org",
sys.env.getOrElse("OSSRH_USERNAME", ""),
sys.env.getOrElse("OSSRH_PASSWORD", "")
)
val localCreds = Credentials(Path.userHome / ".sbt" / "credentials.sbt")
lazy val credentialSettings = Seq(
credentials := (if (isGithubActions) Seq(travisCreds) else Seq(localCreds))
)
lazy val noPublishSettings = Seq(
publish := {},
publishLocal := {},
publishArtifact := false
)
lazy val allSettings = commonScalaVersionSettings ++
commonJvmSettings ++
commonSettings ++
commonDeps ++
credentialSettings ++
pomSettings ++
warnUnusedImport ++
publishSettings
lazy val root = Project("pulsar4s", file("."))
.settings(name := "pulsar4s")
.settings(allSettings)
.settings(noPublishSettings)
.aggregate(
akka_streams,
avro,
cats_effect,
circe,
core,
fs2,
jackson,
json4s,
monix,
pekko_streams,
playjson,
scalaz,
sprayjson,
zio,
)
lazy val core = Project("pulsar4s-core", file("pulsar4s-core"))
.settings(name := "pulsar4s-core")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-java8-compat" % {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => "1.0.2"
case Some((2, n)) if n >= 13 => "1.0.2"
case _ => "0.8.0"
}
},
"org.apache.pulsar" % "pulsar-client" % PulsarVersion
))
lazy val cats_effect = Project("pulsar4s-cats-effect", file("pulsar4s-cats-effect"))
.dependsOn(core)
.settings(name := "pulsar4s-cats-effect")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % CatsEffectVersion,
"io.monix" %% "monix" % MonixVersion % Test,
"dev.zio" %% "zio-interop-cats" % ZIOInteropCatsVersion % Test
))
lazy val fs2 = Project("pulsar4s-fs2", file("pulsar4s-fs2"))
.dependsOn(core)
.dependsOn(cats_effect)
.settings(name := "pulsar4s-fs2")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % CatsEffectVersion,
"co.fs2" %% "fs2-core" % FunctionalStreamsVersion,
"co.fs2" %% "fs2-reactive-streams" % FunctionalStreamsVersion
))
lazy val scalaz = Project("pulsar4s-scalaz", file("pulsar4s-scalaz"))
.dependsOn(core)
.settings(name := "pulsar4s-scalaz")
.settings(allSettings)
.settings(libraryDependencies ++= {
Seq(
"org.scalaz" %% "scalaz-core" % ScalazVersion,
"org.scalaz" %% "scalaz-concurrent" % ScalazVersion,
)
})
lazy val monix = Project("pulsar4s-monix", file("pulsar4s-monix"))
.dependsOn(core)
.settings(name := "pulsar4s-monix")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
"io.monix" %% "monix" % MonixVersion
))
lazy val zio = Project("pulsar4s-zio", file("pulsar4s-zio"))
.dependsOn(core)
.settings(name := "pulsar4s-zio")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
"dev.zio" %% "zio" % ZIOVersion
))
lazy val jackson = Project("pulsar4s-jackson", file("pulsar4s-jackson"))
.dependsOn(core)
.settings(name := "pulsar4s-jackson")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
// For 2.9 releases see https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.9#micro-patches
"com.fasterxml.jackson.core" % "jackson-core" % JacksonVersion,
"com.fasterxml.jackson.core" % "jackson-annotations" % JacksonVersion,
"com.fasterxml.jackson.core" % "jackson-databind" % JacksonVersion,
"com.fasterxml.jackson.module" %% "jackson-module-scala" % JacksonVersion
))
lazy val circe = Project("pulsar4s-circe", file("pulsar4s-circe"))
.dependsOn(core)
.settings(name := "pulsar4s-circe")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
"io.circe" %% "circe-core" % CirceVersion,
"io.circe" %% "circe-generic" % CirceVersion,
"io.circe" %% "circe-parser" % CirceVersion
))
lazy val playjson = Project("pulsar4s-play-json", file("pulsar4s-play-json"))
.dependsOn(core)
.settings(name := "pulsar4s-play-json")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % PlayJsonVersion
))
lazy val json4s = Project("pulsar4s-json4s", file("pulsar4s-json4s"))
.dependsOn(core)
.settings(name := "pulsar4s-json4s")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
"org.json4s" %% "json4s-core" % Json4sVersion,
"org.json4s" %% "json4s-jackson" % Json4sVersion
))
lazy val sprayjson = Project("pulsar4s-spray-json", file("pulsar4s-spray-json"))
.dependsOn(core)
.settings(name := "pulsar4s-spray-json")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
"io.spray" %% "spray-json" % SprayJsonVersion
))
lazy val avro = Project("pulsar4s-avro", file("pulsar4s-avro"))
.dependsOn(core)
.settings(name := "pulsar4s-avro")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
"com.sksamuel.avro4s" %% "avro4s-core" % (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Avro4sVersionFor3
case _ => Avro4sVersionFor2
})
))
lazy val akka_streams = Project("pulsar4s-akka-streams", file("pulsar4s-akka-streams"))
.dependsOn(core)
.settings(name := "pulsar4s-akka-streams")
.settings(allSettings)
.settings(libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-stream" % AkkaStreamVersion
))
lazy val pekko_streams = Project("pulsar4s-pekko-streams", file("pulsar4s-pekko-streams"))
.dependsOn(core)
.settings(name := "pulsar4s-pekko-streams")
.settings(allSettings)
.settings(
libraryDependencies ++= Seq(
"org.apache.pekko" %% "pekko-stream" % PekkoStreamVersion
),
// ignore scala-java8-compat issues with scala 2.12
libraryDependencySchemes ++= (CrossVersion.partialVersion(scalaVersion.value).collect {
case (2, 12) => "org.scala-lang.modules" %% "scala-java8-compat" % VersionScheme.Always
})
)