This repository has been archived by the owner on Feb 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sbt
379 lines (334 loc) · 12.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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
import scalariform.formatter.preferences._
import com.scalapenos.sbt.prompt._
import SbtPrompt.autoImport._
import com.typesafe.sbt.SbtScalariform
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
import ReleaseTransformations._
import scala.xml.transform.{RewriteRule, RuleTransformer}
import scalariform.formatter.preferences.AlignSingleLineCaseStatements.MaxArrowIndent
///////////////////////////////////////////////////////////////////////////////////////////////////
// Settings
///////////////////////////////////////////////////////////////////////////////////////////////////
promptTheme := PromptTheme(List(
text("[SBT] ", fg(136)),
currentProject(fg(64)).padRight(": ")
))
lazy val tagName = Def.setting{
s"v${if (releaseUseGlobalVersion.value) (version in ThisBuild).value else version.value}"
}
lazy val buildSettings = Seq(
organization := "io.pjan",
scalaVersion := "2.12.7",
crossScalaVersions := Seq("2.11.12", "2.12.7")
)
lazy val noPublishSettings = Seq(
publish := { },
publishLocal := { },
publishArtifact := false
)
lazy val noTests = Seq(
test in test := { },
coverageEnabled := false
)
lazy val publishSettings = Seq(
homepage := Some(url("https://github.com/pjan/akka-d3")),
licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT")),
scmInfo := Some(ScmInfo(url("https://github.com/pjan/akka-d3"), "scm:git:[email protected]:pjan/akka-d3.git")),
autoAPIMappings := true,
pomExtra :=
<developers>
<developer>
<id>pjan</id>
<name>pjan vandaele</name>
<url>https://github.com/pjan/</url>
</developer>
</developers>
) ++ credentialSettings ++ sharedPublishSettings ++ sharedReleaseProcess
lazy val credentialSettings = Seq(
// For Travis CI - see http://www.cakesolutions.net/teamblogs/publishing-artefacts-to-oss-sonatype-nexus-using-sbt-and-travis-ci
credentials ++= (for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq
)
lazy val sharedPublishSettings = Seq(
useGpg := true,
releaseCrossBuild := true,
releaseTagName := tagName.value,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := Function.const(false),
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")
}
)
lazy val sharedReleaseProcess = Seq(
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
releaseStepCommand("build"),
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
setNextVersion,
commitNextVersion,
ReleaseStep(action = Command.process("sonatypeReleaseAll", _), enableCrossBuild = true)
// pushChanges
)
)
lazy val commonSettings = Seq(
incOptions := incOptions.value.withLogRecompileOnMacro(false),
scalacOptions ++= commonScalacOptions,
libraryDependencies ++= Seq(
compilerPlugin(D.macroParadise),
compilerPlugin(D.kindProjector)
),
fork in test := true,
parallelExecution in Test := false,
scalacOptions in (Compile, doc) := (scalacOptions in (Compile, doc)).value.filter(_ != "-Xfatal-warnings"),
// workaround for https://github.com/scalastyle/scalastyle-sbt-plugin/issues/47
scalastyleSources in Compile ++= (unmanagedSourceDirectories in Compile).value
) ++ warnUnusedImport
lazy val formatSettings = SbtScalariform.scalariformSettings ++ Seq(
ScalariformKeys.preferences := ScalariformKeys.preferences.value
.setPreference(RewriteArrowSymbols, true)
.setPreference(DoubleIndentClassDeclaration, true)
.setPreference(PreserveSpaceBeforeArguments, true)
.setPreference(AlignParameters, true)
.setPreference(AlignSingleLineCaseStatements, true)
.setPreference(MaxArrowIndent, 75)
)
lazy val commonScalacOptions = Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-language:experimental.macros",
"-unchecked",
"-Xfatal-warnings",
"-Xlint",
// "-Yinline-warnings",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfuture",
"-Xlog-reflective-calls",
"-Ywarn-inaccessible",
"-Ypatmat-exhaust-depth", "20",
// "-Ybackend:GenBCode",
"-Ydelambdafy:method"
)
lazy val commonJvmSettings = Seq(
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDF")
)
lazy val promptSettings = Seq(
promptTheme := PromptTheme(List(
text("[SBT] ", fg(136)),
currentProject(fg(64)).padRight(": ")
))
)
lazy val protobufSettings = akka.Protobuf.settings
lazy val scoverageSettings = Seq(
coverageMinimum := 60,
coverageFailOnMinimum := false,
coverageExcludedPackages := ".*generated.*;.*protobuf.*",
// don't include scoverage as a dependency in the pom
// see issue #980
// this code was copied from https://github.com/mongodb/mongo-spark
pomPostProcess := { (node: xml.Node) =>
new RuleTransformer(
new RewriteRule {
override def transform(node: xml.Node): Seq[xml.Node] = node match {
case e: xml.Elem if e.label == "dependency" && e.child.exists(child => child.label == "groupId" && child.text == "org.scoverage") =>
Nil
case _ =>
Seq(node)
}
}
).transform(node).head
}
)
lazy val warnUnusedImport = Seq(
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 10)) =>
Seq()
case Some((2, n)) if n >= 11 =>
Seq("-Ywarn-unused-import")
}
},
scalacOptions in (Compile, console) ~= {_.filterNot("-Ywarn-unused-import" == _)},
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value
)
lazy val wartRemoverSettings = Seq(
wartremoverErrors ++= Warts.unsafe
)
lazy val micrositesSettings = Seq(
micrositeName := "akka-d3",
micrositeDescription := "Library for Domain Driven Design, embracing Event Sourcing and CQRS, on top of Akka",
micrositeBaseUrl := "akka-d3",
micrositeDocumentationUrl := "/akka-d3/docs/",
micrositeGithubOwner := "pjan",
micrositeGithubRepo := "akka-d3",
micrositeAuthor := "pjan",
micrositeHighlightTheme := "solarized-dark",
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.md"
)
lazy val buildInfoSettings = Seq(
buildInfoKeys := Seq[BuildInfoKey](
name,
version,
scalaVersion,
sbtVersion,
"lastTag" -> git.gitDescribedVersion.value.get.takeWhile(_ != '-')
),
buildInfoPackage := "akka.contrib.d3"
)
lazy val d3Settings = buildSettings ++ commonSettings ++ publishSettings ++ formatSettings ++ promptSettings ++ scoverageSettings
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependencies
///////////////////////////////////////////////////////////////////////////////////////////////////
lazy val D = new {
val Versions = new {
val akka = "2.5.17"
val akkaPersistenceCassandra = "0.91"
val akkaPersistenceInMemory = "2.5.1.1"
// Test
val scalaTest = "3.0.5"
// Compiler
val kindProjector = "0.9.8"
val macroParadise = "2.1.1"
}
val akkaActor = "com.typesafe.akka" %% "akka-actor" % Versions.akka
val akkaClusterSharding = "com.typesafe.akka" %% "akka-cluster-sharding" % Versions.akka
val akkaPersistence = "com.typesafe.akka" %% "akka-persistence" % Versions.akka
val akkaPersistenceCassandra = "com.typesafe.akka" %% "akka-persistence-cassandra" % Versions.akkaPersistenceCassandra
val akkaPersistenceInMemory = "com.github.dnvriend" %% "akka-persistence-inmemory" % Versions.akkaPersistenceInMemory
val akkaPersistenceQuery = "com.typesafe.akka" %% "akka-persistence-query" % Versions.akka
// Test
val akkaTest = "com.typesafe.akka" %% "akka-testkit" % Versions.akka
val scalaTest = "org.scalatest" %% "scalatest" % Versions.scalaTest
// Compiler
val kindProjector = "org.spire-math" %% "kind-projector" % Versions.kindProjector // cross CrossVersion.full
val macroParadise = "org.scalamacros" %% "paradise" % Versions.macroParadise cross CrossVersion.full
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Projects
///////////////////////////////////////////////////////////////////////////////////////////////////
lazy val root = Project(
id = "akka-d3",
base = file(".")
)
.settings(moduleName := "root")
.settings(d3Settings)
.settings(noPublishSettings)
.aggregate(d3, queryCassandra, queryInmemory, readsideCassandra)
.dependsOn(d3, queryCassandra, queryInmemory, readsideCassandra)
lazy val d3 = project.in(file(".d3"))
.settings(moduleName := "akka-d3")
.settings(d3Settings)
.settings(commonJvmSettings)
.aggregate(core, cluster)
.dependsOn(core, cluster)
lazy val docs = Project(
id = "docs",
base = file("docs")
)
.settings(moduleName := "docs")
.settings(d3Settings)
.settings(micrositesSettings)
.settings(buildInfoSettings)
.dependsOn(root)
.enablePlugins(MicrositesPlugin)
.enablePlugins(BuildInfoPlugin)
lazy val core = Project(
id = "core",
base = file("akka-d3-core")
)
.settings(moduleName := "akka-d3-core")
.settings(
libraryDependencies ++= Seq(
D.akkaActor,
D.akkaPersistence,
D.akkaPersistenceQuery,
D.akkaTest % "test",
D.scalaTest % "test",
D.akkaPersistenceInMemory % "test"
)
)
.settings(d3Settings)
.settings(commonJvmSettings)
.settings(protobufSettings)
lazy val cluster = Project(
id = "cluster",
base = file("akka-d3-cluster")
)
.settings(moduleName := "akka-d3-cluster")
.settings(
libraryDependencies ++= Seq(
D.akkaClusterSharding,
D.akkaTest % "test",
D.scalaTest % "test",
D.akkaPersistenceInMemory % "test"
)
)
.dependsOn(core)
.settings(d3Settings)
.settings(commonJvmSettings)
lazy val queryInmemory = Project(
id = "query-inmemory",
base = file("akka-d3-query-inmemory")
)
.settings(moduleName := "akka-d3-query-inmemory")
.settings(
libraryDependencies ++= Seq(
D.akkaPersistenceInMemory
)
)
.dependsOn(core)
.settings(d3Settings)
.settings(commonJvmSettings)
lazy val queryCassandra = Project(
id = "query-cassandra",
base = file("akka-d3-query-cassandra")
)
.settings(moduleName := "akka-d3-query-cassandra")
.settings(
libraryDependencies ++= Seq(
D.akkaPersistenceCassandra
)
)
.dependsOn(core)
.settings(d3Settings)
.settings(commonJvmSettings)
lazy val readsideCassandra = Project(
id = "readside-cassandra",
base = file("akka-d3-readside-cassandra")
)
.settings(moduleName := "akka-d3-readside-cassandra")
.settings(
libraryDependencies ++= Seq(
D.akkaPersistenceCassandra,
// fix for SI-8978
"com.google.code.findbugs" % "jsr305" % "3.0.2"
)
)
.dependsOn(core, queryCassandra)
.settings(d3Settings)
.settings(commonJvmSettings)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Commands
///////////////////////////////////////////////////////////////////////////////////////////////////
addCommandAlias("gitSnapshots", ";set version in ThisBuild := git.gitDescribedVersion.value.get + \"-SNAPSHOT\"")
addCommandAlias("build", ";clean;scalariformFormat;scalastyle;protobufGenerate;test")
addCommandAlias("validate", ";clean;scalastyle;protobufGenerate;test;docs/makeMicrosite")