forked from monix/monix-kafka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
279 lines (246 loc) · 10.2 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
val monixVersion = "3.2.1"
val allProjects = List(
"kafka1x",
"kafka11",
"kafka10"
)
addCommandAlias("ci", s";clean ;test:compile ;${allProjects.map(_ + "/test").mkString(" ;")} ;doc")
addCommandAlias("release", ";+clean ;+package ;+publishSigned ;sonatypeReleaseAll")
lazy val doNotPublishArtifact = Seq(
publishArtifact := false,
publishArtifact in (Compile, packageDoc) := false,
publishArtifact in (Compile, packageSrc) := false,
publishArtifact in (Compile, packageBin) := false
)
lazy val warnUnusedImport = Seq(
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) =>
Seq("-Ywarn-unused-import")
case _ =>
Seq("-Ywarn-unused:imports")
}
},
scalacOptions in (Compile, console) --= Seq("-Ywarn-unused-import", "-Ywarn-unused:imports"),
scalacOptions in Test --= Seq("-Ywarn-unused-import", "-Ywarn-unused:imports")
)
lazy val sharedSettings = warnUnusedImport ++ Seq(
organization := "io.monix",
scalaVersion := "2.12.10",
crossScalaVersions := Seq("2.11.12", "2.12.10", "2.13.1"),
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",
// possibly deprecated options
"-Ywarn-dead-code",
"-language:higherKinds",
"-language:existentials"
),
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, majorVersion)) if majorVersion <= 12 =>
Seq(
"-Xlint:inaccessible", // warn about inaccessible types in method signatures
"-Xlint:by-name-right-associative", // By-name parameter of right associative operator
"-Xlint:unsound-match" // Pattern match may not be typesafe
)
case _ =>
Seq.empty
}),
// Targeting Java 6, but only for Scala <= 2.11
javacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, majorVersion)) if majorVersion <= 11 =>
// generates code with the Java 6 class format
Seq("-source", "1.6", "-target", "1.6")
case _ =>
// For 2.12 we are targeting the Java 8 class format
Seq.empty
}),
// Targeting Java 6, but only for Scala <= 2.11
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, majorVersion)) if majorVersion <= 11 =>
// generates code with the Java 6 class format
Seq("-target:jvm-1.6")
case _ =>
// For 2.12 we are targeting the Java 8 class format
Seq.empty
}),
// Linter
scalacOptions ++= Seq(
// Turns all warnings into errors ;-)
// TODO: enable after fixing deprecations for Scala 2.13
// "-Xfatal-warnings",
// Enables linter options
"-Xlint:adapted-args", // warn if an argument list is modified to match the receiver
"-Xlint:nullary-unit", // warn when nullary methods return Unit
"-Xlint:nullary-override", // warn when non-nullary `def f()' overrides nullary `def f'
"-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
),
scalacOptions in doc ++=
Opts.doc.title(s"Monix"),
scalacOptions in doc ++=
Opts.doc.sourceUrl(s"https://github.com/monix/monix-kafka/tree/v${version.value}€{FILE_PATH}.scala"),
scalacOptions in doc ++=
Seq("-doc-root-content", file("docs/rootdoc.txt").getAbsolutePath),
scalacOptions in doc ++=
Opts.doc.version(s"${version.value}"),
// ScalaDoc settings
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 := false,
parallelExecution in IntegrationTest := false,
testForkedParallel in Test := false,
testForkedParallel in IntegrationTest := false,
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1),
licenses := Seq("APL2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
homepage := Some(url("https://github.com/monix/monix-kafka")),
headerLicense := Some(HeaderLicense.Custom(
"""|Copyright (c) 2014-2019 by The Monix Project Developers.
|
|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)),
scmInfo := Some(
ScmInfo(
url("https://github.com/monix/monix-kafka"),
"scm:[email protected]:monix/monix-kafka.git"
)),
developers := List(
Developer(
id="alexelcu",
name="Alexandru Nedelcu",
email="[email protected]",
url=url("https://alexn.org")
),
Developer(
id="pgawrys",
name="Piotr Gawryś",
email="[email protected]",
url=url("https://github.com/Avasil")
)),
// -- Settings meant for deployment on oss.sonatype.org
publishMavenStyle := true,
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
publishArtifact in Test := false,
pomIncludeRepository := { _ => false } // removes optional dependencies
)
def mimaSettings(projectName: String) = Seq(
mimaPreviousArtifacts := Set("io.monix" %% projectName % "1.0.0-RC5")
)
lazy val commonDependencies = Seq(
resolvers ++= Seq(
"Typesafe Releases" at "https://repo.typesafe.com/typesafe/releases",
Resolver.sonatypeRepo("releases")
),
libraryDependencies ++= Seq(
"io.monix" %% "monix-reactive" % monixVersion,
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.2",
"com.typesafe" % "config" % "1.4.0",
"org.slf4j" % "log4j-over-slf4j" % "1.7.30",
// For testing ...
"ch.qos.logback" % "logback-classic" % "1.2.3" % "test",
"org.scalatest" %% "scalatest" % "3.0.8" % "test",
"org.scalacheck" %% "scalacheck" % "1.14.3" % "test"
)
)
lazy val monixKafka = project.in(file("."))
.settings(sharedSettings)
.settings(doNotPublishArtifact)
.aggregate(kafka1x, kafka11, kafka10, kafka9)
lazy val kafka1x = project.in(file("kafka-1.0.x"))
.settings(sharedSettings)
.settings(commonDependencies)
.settings(mimaSettings("monix-kafka-1x"))
.settings(
name := "monix-kafka-1x",
libraryDependencies ++= {
if (!(scalaVersion.value startsWith "2.13")) Seq("net.manub" %% "scalatest-embedded-kafka" % "1.0.0" % "test" exclude ("log4j", "log4j"))
else Seq.empty[ModuleID]
},
libraryDependencies += "org.apache.kafka" % "kafka-clients" % "1.0.2" exclude("org.slf4j","slf4j-log4j12") exclude("log4j", "log4j")
)
lazy val kafka11 = project.in(file("kafka-0.11.x"))
.settings(sharedSettings)
.settings(commonDependencies)
.settings(mimaSettings("monix-kafka-11"))
.settings(
name := "monix-kafka-11",
libraryDependencies ++= {
if (!(scalaVersion.value startsWith "2.13")) Seq("net.manub" %% "scalatest-embedded-kafka" % "1.0.0" % "test" exclude ("log4j", "log4j"))
else Seq.empty[ModuleID]
},
libraryDependencies += "org.apache.kafka" % "kafka-clients" % "0.11.0.3" exclude("org.slf4j","slf4j-log4j12") exclude("log4j", "log4j")
)
lazy val kafka10 = project.in(file("kafka-0.10.x"))
.settings(sharedSettings)
.settings(commonDependencies)
.settings(mimaSettings("monix-kafka-10"))
.settings(
name := "monix-kafka-10",
libraryDependencies ++= {
if (!(scalaVersion.value startsWith "2.13")) Seq("net.manub" %% "scalatest-embedded-kafka" % "0.16.0" % "test" exclude ("log4j", "log4j"))
else Seq.empty[ModuleID]
},
libraryDependencies += "org.apache.kafka" % "kafka-clients" % "0.10.2.2" exclude("org.slf4j","slf4j-log4j12") exclude("log4j", "log4j")
)
lazy val kafka9 = project.in(file("kafka-0.9.x"))
.settings(sharedSettings)
.settings(commonDependencies)
.settings(mimaSettings("monix-kafka-9"))
.settings(
name := "monix-kafka-9",
libraryDependencies ++= Seq(
"org.apache.kafka" % "kafka-clients" % "0.9.0.1" exclude("org.slf4j","slf4j-log4j12") exclude("log4j", "log4j")
)
)
//------------- For Release
enablePlugins(GitVersioning)
isSnapshot := version.value endsWith "SNAPSHOT"
/* The BaseVersion setting represents the previously released version. */
git.baseVersion := "1.0.0-RC6"
val ReleaseTag = """^v(\d+\.\d+(?:\.\d+(?:[-.]\w+)?)?)$""".r
git.gitTagToVersionNumber := {
case ReleaseTag(v) => Some(v)
case _ => None
}
git.formattedShaVersion := {
val suffix = git.makeUncommittedSignifierSuffix(git.gitUncommittedChanges.value, git.uncommittedSignifier.value)
git.gitHeadCommit.value map { _.substring(0, 7) } map { sha =>
git.baseVersion.value + "-" + sha + suffix
}
}