-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathbuild.sbt
340 lines (300 loc) Β· 13.1 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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
import Dependencies.Versions
import sbt.Keys.version
val monixConnectSeries = "0.7.0"
inThisBuild(List(
organization := "io.monix",
homepage := Some(url("https://connect.monix.io")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
"paualarco",
"Pau AlarcΓ³n Cerdan",
url("https://connect.monix.io")
)
)
))
skip in publish := true //required by sbt-ci-release
def sharedSettings(publishForScala3: Boolean= true) = {
Seq(
scalaVersion := "2.13.8",
crossScalaVersions := Seq("2.12.17", "2.13.8") ++ (if (publishForScala3) Seq("3.1.2") else Seq.empty)
,
publishArtifact := (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => publishForScala3
case _ => true
}),
scalafmtOnCompile := false
,
mimaFailOnNoPrevious := false,
scalacOptions ++= Seq(
// warnings
"-unchecked", // able additional warnings where generated code depends on assumptions
"-deprecation", // emit warning for usages of deprecated APIs
"-feature", // emit warning usages of features that should be imported explicitly
// Features enabled by default
"-language:higherKinds",
"-language:implicitConversions",
"-language:experimental.macros"
),
//warnUnusedImports
scalacOptions in(Compile, console) ++= Seq("-Ywarn-unused:imports")
,
// Linter
scalacOptions ++= Seq(
"-Ywarn-unused:imports", // Warn if an import selector is not referenced.
"-Ywarn-dead-code", // Warn when dead code is identified.
// Turns all warnings into errors ;-)
//temporary disabled for mongodb warn, -YWarn (2.13) and Silencer (2.12) should fix it...
//"-Xfatal-warnings", //Turning of fatal warnings for the moment
// Enables linter options
"-Xlint:adapted-args", // warn if an argument list is modified to match the receiver
"-Xlint:infer-any", // warn when a type argument is inferred to be `Any`
"-Xlint:missing-interpolator", // a string literal appears to be missing an interpolator id
"-Xlint:doc-detached", // a ScalaDoc comment appears to be detached from its element
"-Xlint:private-shadow", // a private field (or class parameter) shadows a superclass field
"-Xlint:type-parameter-shadow", // a local type parameter shadows a type already in scope
"-Xlint:poly-implicit-overload", // parameterized overloaded implicit methods are not visible as view bounds
"-Xlint:option-implicit", // Option.apply used implicit view
"-Xlint:delayedinit-select", // Selecting member of DelayedInit
//"-Xlint:package-object-classes" // Class or object defined in package object
)
,
// ScalaDoc settings
scalacOptions in(Compile, doc) ++= Seq("-no-link-warnings")
,
autoAPIMappings := true
,
scalacOptions in ThisBuild ++= Seq(
// Note, this is used by the doc-source-url feature to determine the
// relative path of a given source file. If it's not a prefix of a the
// absolute path of the source file, the absolute path of that file
// will be put into the FILE_SOURCE variable, which is
// definitely not what we want.
"-sourcepath",
file(".").getAbsolutePath.replaceAll("[.]$", "")
)
,
parallelExecution in Test := true
,
parallelExecution in ThisBuild := true
,
testForkedParallel in Test := true
,
testForkedParallel in ThisBuild := true
,
concurrentRestrictions in Global += Tags.limit(Tags.Test, 3)
,
logBuffered in Test := false
,
logBuffered in IntegrationTest := false
,
//dependencyClasspath in IntegrationTest := (dependencyClasspath in IntegrationTest).value ++ (exportedProducts in Test).value,
// https://github.com/sbt/sbt/issues/2654
incOptions := incOptions.value.withLogRecompileOnMacro(false)
,
pomIncludeRepository := { _ => false }
, // removes optional dependencies
// ScalaDoc settings
autoAPIMappings := true
,
apiURL := Some(url("https://monix.github.io/monix-connect/api/"))
,
headerLicense := Some(HeaderLicense.Custom(
"""|Copyright (c) 2020-2021 by The Monix Connect Project Developers.
|See the project homepage at: https://connect.monix.io
|
|Licensed under the Apache License, Version 2.0 (the "License");
|you may not use this file except in compliance with the License.
|You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
|Unless required by applicable law or agreed to in writing, software
|distributed under the License is distributed on an "AS IS" BASIS,
|WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|See the License for the specific language governing permissions and
|limitations under the License."""
.stripMargin))
,
doctestTestFramework := DoctestTestFramework.ScalaTest
,
doctestTestFramework := DoctestTestFramework.ScalaCheck
,
doctestOnlyCodeBlocksMode := true,
)
}
def mimaSettings(projectName: String) = Seq(
mimaPreviousArtifacts := {
/**
* Needed in order to avoid running mima compatibility checks when compatibility series is equal to the project
* version. Because in such case the compatibility series version does not exist and the mima checks would
* otherwise fail.
*/
val isFirstCompatibilitySeriesRelease = monixConnectSeries.endsWith("0")
if (isFirstCompatibilitySeriesRelease) {
Set.empty
} else {
Set("io.monix" %% projectName % monixConnectSeries)
}
},
mimaBinaryIssueFilters ++= MimaFilters.allMimaFilters
)
mimaFailOnNoPrevious in ThisBuild := false
//ignores scaladoc link warnings (which are
scalacOptions in (Compile, doc) ++= Seq("-no-link-warnings")
val IT = config("it") extend Test
//=> published modules
lazy val monixConnect = (project in file("."))
.configs(IntegrationTest, IT)
.settings(sharedSettings())
.settings(name := "monix-connect")
.aggregate(dynamodb, parquet, gcs, hdfs, mongodb, redis, s3, sqs, elasticsearch, awsAuth)
.dependsOn(dynamodb, parquet, gcs, hdfs, mongodb, redis, s3, sqs, elasticsearch, awsAuth)
lazy val dynamodb = monixConnector("dynamodb", Dependencies.DynamoDb).aggregate(awsAuth).dependsOn(awsAuth % "compile->compile;test->test")
.settings(libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Seq.empty
case _ => Seq("org.mockito" %% "mockito-scala" % Versions.Mockito % Test)
}))
lazy val hdfs = monixConnector("hdfs", Dependencies.Hdfs)
.settings(libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Seq.empty
case _ => Seq("org.mockito" %% "mockito-scala" % Versions.Mockito % Test)
}))
lazy val mongodb = monixConnector("mongodb", Dependencies.MongoDb, isMimaEnabled = false, isITParallelExecution = true, scala3Publish = false)
.settings(libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Seq.empty
case _ => Seq(
"org.mongodb.scala" %% "mongo-scala-driver" % Versions.MongoScala,
"org.mongodb.scala" %% "mongo-scala-bson" % Versions.MongoScala % Test,
"org.mockito" %% "mockito-scala" % Versions.Mockito % Test cross CrossVersion.for3Use2_13)
}))
lazy val parquet = monixConnector("parquet", Dependencies.Parquet, scala3Publish = false)
.settings(libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Seq.empty
case _ => Seq("org.mockito" %% "mockito-scala" % Versions.Mockito % Test)
}))
val protoTestSettings = Seq(
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
)
//Compile / PB.protoSources := Seq(new File("src/test/protobuf"))
)
lazy val redis = monixConnector("redis", Dependencies.Redis, isITParallelExecution = false)
.settings(protoTestSettings)
lazy val s3 = monixConnector("s3", Dependencies.S3, isMimaEnabled = false, isITParallelExecution = true)
.aggregate(awsAuth).dependsOn(awsAuth % "compile->compile;test->test")
lazy val sqs = monixConnector("sqs", Dependencies.Sqs, isMimaEnabled = false, isITParallelExecution = true)
.aggregate(awsAuth).dependsOn(awsAuth % "compile->compile;test->test")
lazy val gcs = monixConnector("gcs", Dependencies.GCS , isITParallelExecution = false)
.settings(libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Seq.empty
case _ => Seq("org.mockito" %% "mockito-scala" % Versions.Mockito % Test)
}))
lazy val elasticsearch = monixConnector("elasticsearch", Dependencies.Elasticsearch, isITParallelExecution = true)
//internal
lazy val awsAuth = monixConnector("aws-auth", Dependencies.AwsAuth, isMimaEnabled = false)
def monixConnector(
connectorName: String,
projectDependencies: Seq[ModuleID],
isMimaEnabled: Boolean = true,
isITParallelExecution: Boolean = false,
scala3Publish: Boolean = true) = {
Project(id = connectorName, base = file(connectorName))
.enablePlugins(AutomateHeaderPlugin)
.settings(name := s"monix-$connectorName",
libraryDependencies ++= projectDependencies,
Defaults.itSettings,
IntegrationTest / parallelExecution := isITParallelExecution,
IntegrationTest / testForkedParallel := isITParallelExecution
)
.settings(sharedSettings(scala3Publish))
.configs(IntegrationTest, IT)
.enablePlugins(AutomateHeaderPlugin)
.settings(
if(isMimaEnabled) {
mimaSettings(s"monix-$connectorName")
} else { Seq.empty },
Compile / doc / sources := { if (scalaVersion.value.startsWith("3.")) Seq.empty else (Compile / doc / sources).value },
Test / doc / sources := { if (scalaVersion.value.startsWith("3.")) Seq.empty else (Compile / doc / sources).value }
)
}
//=> non published modules
lazy val benchmarks = monixConnector("benchmarks", Dependencies.Benchmarks, isMimaEnabled = false)
.enablePlugins(JmhPlugin)
.settings(skipOnPublishSettings)
.dependsOn(parquet % "compile->compile;test->test", redis % "compile->compile;test->test", s3 % "compile->compile;test->test")
.aggregate(parquet, redis, s3)
lazy val docs = project
.in(file("monix-connect-docs"))
.settings(
moduleName := "monix-connect-docs",
name := moduleName.value,
sharedSettings(publishForScala3 = false),
skipOnPublishSettings,
mdocSettings
)
.enablePlugins(DocusaurusPlugin, MdocPlugin, ScalaUnidocPlugin)
lazy val skipOnPublishSettings = Seq(
skip in publish := true,
publishArtifact := false,
)
lazy val mdocSettings = Seq(
scalacOptions --= Seq("-Xfatal-warnings", "-Ywarn-unused"),
crossScalaVersions := Seq(scalaVersion.value),
unidocProjectFilter in (ScalaUnidoc, unidoc) := inProjects(parquet, dynamodb, s3, sqs, elasticsearch, gcs, hdfs, mongodb, redis),
target in (ScalaUnidoc, unidoc) := (baseDirectory in LocalRootProject).value / "website" / "static" / "api",
cleanFiles += (target in (ScalaUnidoc, unidoc)).value,
docusaurusCreateSite := docusaurusCreateSite
.dependsOn(unidoc in Compile)
.dependsOn(updateSiteVariables in ThisBuild)
.value,
docusaurusPublishGhpages :=
docusaurusPublishGhpages
.dependsOn(unidoc in Compile)
.dependsOn(updateSiteVariables in ThisBuild)
.value,
scalacOptions in (ScalaUnidoc, unidoc) ++= Seq(
"-doc-source-url", s"https://github.com/monix/monix-connect/tree/v${version.value}β¬{FILE_PATH}.scala",
"-sourcepath", baseDirectory.in(LocalRootProject).value.getAbsolutePath,
"-doc-title", "Monix Connect",
"-doc-version", s"v${version.value}",
"-groups"
),
// Exclude monix.*.internal from ScalaDoc
sources in (ScalaUnidoc, unidoc) ~= (_ filterNot { file =>
// Exclude protobuf generated files
file.getCanonicalPath.contains("/src_managed/main/monix/connect/")
file.getCanonicalPath.contains("monix-connect/redis/target/scala-2.12/src_managed")
file.getCanonicalPath.contains("monix-connect/redis/target/scala-2.13/src_managed")
}),
)
def minorVersion(version: String): String = {
val (major, minor) =
CrossVersion.partialVersion(version).get
s"$major.$minor"
}
val updateSiteVariables = taskKey[Unit]("Update site variables")
updateSiteVariables in ThisBuild := {
val file =
(baseDirectory in LocalRootProject).value / "website" / "variables.js"
val variables =
Map[String, String](
"organization" -> (organization in LocalRootProject).value,
"coreModuleName" -> (moduleName in monixConnect).value,
"latestVersion" -> version.value,
"scalaPublishVersions" -> {
val minorVersions = (crossScalaVersions in monixConnect).value.map(minorVersion)
if (minorVersions.size <= 2) minorVersions.mkString(" and ")
else minorVersions.init.mkString(", ") ++ " and " ++ minorVersions.last
}
)
val fileHeader =
"// Generated by sbt. Do not edit directly."
val fileContents =
variables.toList
.sortBy { case (key, _) => key }
.map { case (key, value) => s" $key: '$value'" }
.mkString(s"$fileHeader\nmodule.exports = {\n", ",\n", "\n};\n")
IO.write(file, fileContents)
}