-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.sbt
227 lines (211 loc) · 7.93 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
import Dependencies.*
import sbtversionpolicy.Compatibility.None
val scala213 = "2.13.15"
val scala3 = "3.5.1"
val commonSettings = Seq(
wartremoverExcluded += sourceManaged.value,
Compile / compile / wartremoverErrors ++= Warts.allBut(
Wart.Any,
Wart.Nothing,
Wart.ImplicitParameter,
Wart.Throw,
Wart.DefaultArguments
),
scalaVersion := scala213,
crossScalaVersions := Seq(scala213, scala3),
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) =>
Seq(compilerPlugin("org.typelevel" % "kind-projector" % "0.13.3" cross CrossVersion.full))
case _ => Nil
}),
Compile / scalacOptions ++= Seq("-Xfatal-warnings"),
Compile / scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Seq("-Xkind-projector:underscores")
case Some((2, _)) =>
Seq("-Xsource:3", "-P:kind-projector:underscore-placeholders", "-Xlint:unused")
case _ => Nil
})
)
inThisBuild(
List(
organization := "io.github.endless4s",
homepage := Some(url("https://github.com/endless4s/endless")),
licenses := List("MIT License" -> url("http://opensource.org/licenses/mit-license.php")),
developers := List(
Developer(
"jchapuis",
"Jonas Chapuis",
url("https://jonaschapuis.com")
)
),
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeProjectHosting := Some(
xerial.sbt.Sonatype.GitHubHosting("endless4s", "endless", "[email protected]")
),
Global / onChangedBuildSource := ReloadOnSourceChanges,
PB.protocVersion := "3.17.3", // works on Apple Silicon,
versionPolicyIntention := Compatibility.None,
versionScheme := Some("early-semver"),
versionPolicyIgnoredInternalDependencyVersions := Some(
"^\\d+\\.\\d+\\.\\d+\\+\\d+".r
), // Support for versions generated by sbt-dynver
coverageExcludedPackages := "<empty>;endless.test.*"
)
)
lazy val core = (project in file("core"))
.settings(commonSettings *)
.settings(
libraryDependencies ++= cats ++ catsEffectKernel ++ log4cats ++
(catsLaws ++ catsEffectLaws ++ catsEffect ++ catsTestkit ++ catsEffectTestKit ++ mUnit ++ catsEffectMUnit ++ scalacheckEffect ++ kittens)
.map(_ % Test)
)
.settings(name := "endless-core")
lazy val akkaRuntime = (project in file("akka-runtime"))
.settings(commonSettings *)
.dependsOn(core)
.settings(
libraryDependencies ++= catsEffectStd ++ akkaProvided ++ log4cats ++ scalapbCustomizations ++ (mUnit :+ akkaTypedTestkit % akkaVersion)
.map(_ % Test)
)
.settings(
Project.inConfig(Test)(sbtprotoc.ProtocPlugin.protobufConfigSettings),
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
),
Test / PB.targets := Seq(
scalapb.gen() -> (Test / sourceManaged).value / "scalapb"
)
)
.settings(name := "endless-runtime-akka")
lazy val pekkoRuntime = (project in file("pekko-runtime"))
.settings(commonSettings *)
.dependsOn(core)
.settings(
libraryDependencies ++= catsEffectStd ++ pekkoProvided ++ log4cats ++ scalapbCustomizations ++ (mUnit ++ logback :+ pekkoTypedTestkit % pekkoVersion)
.map(_ % Test)
)
.settings(
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
),
Test / PB.targets := Seq(
scalapb.gen() -> (Test / sourceManaged).value / "scalapb"
)
)
.settings(name := "endless-runtime-pekko")
lazy val circeHelpers = (project in file("circe"))
.settings(commonSettings *)
.dependsOn(core)
.settings(
libraryDependencies ++= circe ++ mUnit.map(_ % Test)
)
.settings(name := "endless-circe-helpers")
lazy val scodecHelpers = (project in file("scodec"))
.settings(commonSettings *)
.settings(scalaVersion := scala3, crossScalaVersions := Nil) // only scala3 for scodec
.dependsOn(core)
.settings(libraryDependencies ++= scodecCore ++ mUnit.map(_ % Test))
.settings(name := "endless-scodec-helpers")
lazy val protobufHelpers = (project in file("protobuf"))
.settings(commonSettings *)
.dependsOn(core)
.settings(
libraryDependencies ++= scalapbCustomizations ++ mUnit.map(_ % Test)
)
.settings(name := "endless-protobuf-helpers")
.settings(
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
),
Test / PB.targets := Seq(
scalapb.gen() -> (Test / sourceManaged).value / "scalapb"
)
)
lazy val example = (project in file("example"))
.settings(commonSettings *)
.dependsOn(core, akkaRuntime, pekkoRuntime, circeHelpers, protobufHelpers)
.settings(
libraryDependencies ++= catsEffect ++ http4s ++ blaze ++ akka ++ pekko ++ scalapbCustomizations ++ akkaTest ++ pekkoTest ++ logback ++ (mUnit ++ catsEffectMUnit ++ scalacheckEffect ++ log4catsTesting)
.map(_ % Test)
)
.settings(name := "endless-example", run / fork := true, publish / skip := true)
.settings(
Project.inConfig(Test)(sbtprotoc.ProtocPlugin.protobufConfigSettings),
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
),
Test / PB.targets := Seq(
scalapb.gen() -> (Test / sourceManaged).value / "scalapb"
)
)
// Generate API documentation per module, as documented in https://www.scala-sbt.org/sbt-site/api-documentation.html#scaladoc-from-multiple-projects
// Create one configuration per module
val Core = config("core")
val Protobuf = config("protobuf")
val Circe = config("circe")
val Scodec = config("scodec")
val AkkaRuntime = config("akka-runtime")
val PekkoRuntime = config("pekko-runtime")
// For each module define its package prefix and path in documentation API
val scaladocSiteProjects = List(
core -> (Core, "endless", "core"),
protobufHelpers -> (Protobuf, "endless.protobuf", "protobuf"),
scodecHelpers -> (Scodec, "endless.scodec", "scodec"),
circeHelpers -> (Circe, "endless.circe", "circe"),
akkaRuntime -> (AkkaRuntime, "endless.runtime.akka", "akka-runtime"),
pekkoRuntime -> (PekkoRuntime, "endless.runtime.pekko", "pekko-runtime")
)
lazy val documentation = (project in file("documentation"))
.enablePlugins(
ParadoxMaterialThemePlugin,
SitePreviewPlugin,
ParadoxPlugin,
ParadoxSitePlugin,
SiteScaladocPlugin
)
.settings(
paradoxProperties ++= (
scaladocSiteProjects.map { case (_, (_, pkg, path)) =>
s"scaladoc.${pkg}.base_url" -> s"api/${path}"
}.toMap
),
paradoxProperties ++= List(
("akka.min.version" -> akkaVersion),
("pekko.min.version" -> pekkoVersion)
).toMap,
scaladocSiteProjects.flatMap { case (project, (conf, _, path)) =>
SiteScaladocPlugin.scaladocSettings(
conf,
project / Compile / packageDoc / mappings,
s"api/${path}"
)
},
Compile / paradoxProperties ++= Map(
"project.description" -> "Scala library to describe event sourced entities using tagless-final algebras, running with built-in implementations for Akka.",
"project.title" -> "Endless4s",
"project.image" -> "https://endless4s.github.io/logo-open-graph.png"
),
Compile / paradoxMaterialTheme := {
val theme = (Compile / paradoxMaterialTheme).value
val repository =
(ThisBuild / sonatypeProjectHosting).value.get.scmInfo.browseUrl.toURI
theme
.withRepository(repository)
.withFont("Overpass", "Overpass Mono")
.withLogo("logo-symbol-only.svg")
.withFavicon("favicon.png")
.withSocial(repository)
.withColor("blue grey", "red")
.withGoogleAnalytics("G-KKHFXG4VB4")
}
)
lazy val root = project
.in(file("."))
.aggregate(core, akkaRuntime, pekkoRuntime, circeHelpers, scodecHelpers, protobufHelpers, example)
.dependsOn(example)
.settings(commonSettings *)
.settings(crossScalaVersions := Nil)
.settings(publish / skip := true)
.settings(name := "endless")
Compile / mainClass := Some("endless.example.app.pekko.Main")