-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathbuild.sbt
More file actions
327 lines (300 loc) · 14.5 KB
/
Copy pathbuild.sbt
File metadata and controls
327 lines (300 loc) · 14.5 KB
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
import org.typelevel.scalacoptions.ScalacOptions
lazy val websiteScaladocs = taskKey[Unit]("Generate unified scaladoc and copy to website/static/scaladoc")
lazy val `workflows4s` = (project in file("."))
.enablePlugins(ScalaUnidocPlugin)
.settings(commonSettings)
.settings(
ScalaUnidoc / unidoc / unidocProjectFilter := inAnyProject -- inProjects(
`workflows4s-example`,
`workflows4s-web-ui`,
`workflows4s-web-ui-bundle`,
`workflows4s-web-api-shared`.js(scala3Version),
),
websiteScaladocs := {
val log = streams.value.log
val base = (ThisBuild / baseDirectory).value
val targetDir = base / "website" / "static" / "scaladoc"
val _ = (Compile / unidoc).value
val docDir = crossTarget.value / "unidoc"
log.info(s"Copying unified scaladoc from $docDir to $targetDir")
IO.delete(targetDir)
IO.copyDirectory(docDir, targetDir)
log.info(s"Unified scaladoc copied to $targetDir")
},
)
.aggregate(
`workflows4s-core`,
`workflows4s-cats-effect`,
`workflows4s-bpmn`,
`workflows4s-pekko`,
`workflows4s-example`,
`workflows4s-doobie`,
`workflows4s-filesystem`,
`workflows4s-quartz`,
`workflows4s-web-ui`,
`workflows4s-web-ui-bundle`,
`workflows4s-web-api-shared`.js(scala3Version),
`workflows4s-web-api-shared`.jvm(scala3Version),
`workflows4s-web-api-server`,
)
lazy val `workflows4s-core` = (project in file("workflows4s-core"))
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % "2.13.0",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.6",
"io.circe" %% "circe-core" % circeVersion, // for model serialization
"io.circe" %% "circe-generic" % circeVersion, // for model serialization
"com.lihaoyi" %% "sourcecode" % "0.4.4", // for auto naming
"org.typelevel" %% "cats-effect" % "3.7.0" % Test,
"dev.zio" %% "zio" % "2.1.26" % Test,
"dev.zio" %% "zio-interop-cats" % "23.1.0.13" % Test,
"ch.qos.logback" % "logback-classic" % "1.6.1" % Test,
),
Test / parallelExecution := false,
)
lazy val `workflows4s-cats-effect` = (project in file("workflows4s-cats-effect"))
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % "3.7.0",
),
)
.dependsOn(`workflows4s-core` % "compile->compile;test->test")
lazy val `workflows4s-bpmn` = (project in file("workflows4s-bpmn"))
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"org.camunda.bpm.model" % "camunda-bpmn-model" % "7.24.0",
),
)
.dependsOn(`workflows4s-core`)
lazy val `workflows4s-pekko` = (project in file("workflows4s-pekko"))
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"org.apache.pekko" %% "pekko-persistence-typed" % pekkoVersion,
"org.apache.pekko" %% "pekko-cluster-typed" % pekkoVersion,
"org.apache.pekko" %% "pekko-cluster-sharding-typed" % pekkoVersion,
"org.apache.pekko" %% "pekko-persistence-testkit" % pekkoVersion % Test,
"org.apache.pekko" %% "pekko-persistence-jdbc" % "1.1.1" % Test,
"com.h2database" % "h2" % "2.4.240" % Test,
"io.r2dbc" % "r2dbc-h2" % "1.1.0.RELEASE" % Test,
"io.altoo" %% "pekko-kryo-serialization" % "1.5.1",
),
)
.dependsOn(`workflows4s-core` % "compile->compile;test->test")
lazy val `workflows4s-doobie` = (project in file("workflows4s-doobie"))
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "doobie-core" % "1.0.0-RC13",
"io.circe" %% "circe-parser" % circeVersion,
"com.dimafeng" %% "testcontainers-scala-scalatest" % testcontainersScalaVersion % Test,
"com.dimafeng" %% "testcontainers-scala-postgresql" % testcontainersScalaVersion % Test,
"org.postgresql" % "postgresql" % "42.7.13" % Test,
"org.xerial" % "sqlite-jdbc" % "3.53.2.1" % Test,
),
)
.dependsOn(`workflows4s-core` % "compile->compile;test->test")
lazy val `workflows4s-filesystem` = (project in file("workflows4s-filesystem"))
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"co.fs2" %% "fs2-io" % "3.13.0",
),
)
.dependsOn(`workflows4s-core` % "compile->compile;test->test")
lazy val `workflows4s-quartz` = (project in file("workflows4s-quartz"))
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % "3.7.0",
"org.quartz-scheduler" % "quartz" % "2.5.2",
),
)
.dependsOn(`workflows4s-core` % "compile->compile;test->test")
lazy val `workflows4s-web-api-shared` = (projectMatrix in file("workflows4s-web-api-shared"))
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"com.softwaremill.sttp.tapir" %% "tapir-core" % tapirVersion,
"com.softwaremill.sttp.tapir" %% "tapir-json-circe" % tapirVersion,
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion,
"com.softwaremill.sttp.tapir" %% "tapir-apispec-docs" % tapirVersion,
"com.softwaremill.sttp.apispec" %% "jsonschema-circe" % "0.11.10",
),
)
.jvmPlatform(scalaVersions = Seq(scala3Version))
.jsPlatform(scalaVersions = Seq(scala3Version))
lazy val `workflows4s-web-api-server` = (project in file("workflows4s-web-api-server"))
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"com.softwaremill.sttp.tapir" %% "tapir-http4s-server" % tapirVersion,
"com.softwaremill.sttp.tapir" %% "tapir-json-circe" % tapirVersion,
"io.circe" %% "circe-generic" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion,
),
)
.dependsOn(
`workflows4s-core`,
`workflows4s-web-api-shared`.jvm(scala3Version),
)
lazy val `workflows4s-web-ui` = (project in file("workflows4s-web-ui"))
.enablePlugins(ScalaJSPlugin)
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"io.indigoengine" %% "tyrian-io" % "0.14.0",
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion,
"com.softwaremill.sttp.tapir" %% "tapir-sttp-client4" % "1.13.30",
"com.softwaremill.sttp.client4" %% "cats" % "4.0.26",
"org.business4s" %% "forms4s-jsonschema" % "0.2.0",
"org.business4s" %% "forms4s-tyrian" % "0.2.0",
"org.business4s" %% "forms4s-circe" % "0.2.0",
),
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule) },
)
.dependsOn(`workflows4s-core`, `workflows4s-web-api-shared`.js(scala3Version))
lazy val `workflows4s-web-ui-bundle` = (project in file("workflows4s-web-ui-bundle"))
.settings(commonSettings)
.dependsOn(`workflows4s-web-api-shared`.jvm(scala3Version))
.settings(
name := "workflows4s-web-ui-bundle",
libraryDependencies ++= Seq(
"com.softwaremill.sttp.tapir" %% "tapir-files" % tapirVersion,
),
// Def.uncached: sbt 2 would otherwise cache this task by its return value alone and could
// skip it without materializing the files; skipping is instead handled by FileFunction.cached,
// which also checks that the outputs exist.
Compile / resourceGenerators += Def.task(Def.uncached {
val log = streams.value.log
val cacheDir = streams.value.cacheDirectory / "webui-bundleit-cache"
val webUiDir = (`workflows4s-web-ui` / baseDirectory).value
val jsOutputDir = (`workflows4s-web-ui` / Compile / fullLinkJSOutput).value
val outputDir = (Compile / resourceManaged).value
// linked js + the frontend sources vite consumes directly
val inputs = Set(jsOutputDir / "main.js") ++
(webUiDir * ("*.html" || "*.js" || "*.mjs" || "*.css" || "*.json")).get() ++
(webUiDir / "public").allPaths.get()
val cached = FileFunction.cached(cacheDir, FilesInfo.hash) { _ =>
log.info("Bundling webui due to source change or missing output.")
BundleIt.bundle(
from = webUiDir,
to = outputDir,
scalaJSOutputDir = jsOutputDir,
)
}
cached(inputs).toSeq
}),
)
lazy val `workflows4s-example` = (project in file("workflows4s-example"))
.settings(commonSettings)
.settings(
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-ember-server" % "0.23.36",
"org.http4s" %% "http4s-dsl" % "0.23.36",
"org.apache.pekko" %% "pekko-http" % pekkoHttpVersion, // for interacting with the app
"org.apache.pekko" %% "pekko-cluster-sharding-typed" % pekkoVersion, // for realistic example and spawning actors
"org.apache.pekko" %% "pekko-persistence-jdbc" % "1.3.0", // published locally until the release is there
"org.apache.pekko" %% "pekko-serialization-jackson" % "1.6.0",
"com.h2database" % "h2" % "2.4.240",
"io.r2dbc" % "r2dbc-h2" % "1.1.0.RELEASE",
"com.github.pjfanning" %% "pekko-http-circe" % "3.10.1",
"ch.qos.logback" % "logback-classic" % "1.6.1",
"dev.zio" %% "zio" % "2.1.26",
"dev.zio" %% "zio-interop-cats" % "23.1.0.3",
"org.scalamock" %% "scalamock" % "7.5.5" % Test,
"org.apache.pekko" %% "pekko-actor-testkit-typed" % pekkoVersion % Test,
"com.dimafeng" %% "testcontainers-scala-scalatest" % testcontainersScalaVersion % Test,
"com.dimafeng" %% "testcontainers-scala-postgresql" % testcontainersScalaVersion % Test,
"org.postgresql" % "postgresql" % "42.7.13" % Test,
"org.xerial" % "sqlite-jdbc" % "3.53.2.1" % Test,
"org.seleniumhq.selenium" % "selenium-java" % "4.46.0" % Test,
"org.seleniumhq.selenium" % "selenium-chrome-driver" % "4.46.0" % Test,
),
Test / parallelExecution := false, // otherwise akka clusters clash
publish / skip := true,
)
.dependsOn(
`workflows4s-core` % "compile->compile;test->test",
`workflows4s-cats-effect` % "compile->compile;test->test",
`workflows4s-bpmn`,
`workflows4s-pekko` % "compile->compile;test->test",
`workflows4s-doobie` % "compile->compile;test->test",
`workflows4s-filesystem`,
`workflows4s-quartz`,
`workflows4s-web-api-server`,
`workflows4s-web-ui-bundle`,
// no dependency on `workflows4s-web-ui` itself: a JVM app cannot use Scala.js classes, and
// its sjs jars collide with the JVM ones when staged for Docker; the UI arrives via the bundle
)
.enablePlugins(JavaAppPackaging)
.enablePlugins(DockerPlugin)
.settings(
Compile / discoveredMainClasses := Seq("workflows4s.example.api.ServerWithUI"),
dockerExposedPorts := Seq(8080),
dockerBaseImage := "eclipse-temurin:21-jdk",
dockerUpdateLatest := true,
dockerBuildOptions ++= Seq("--platform=linux/amd64"),
reStart / mainClass := Some("workflows4s.example.api.Server"),
)
// fully qualified: the sbt-revolver fork auto-imports an ambiguous second `Revolver` object
.settings(spray.revolver.RevolverPlugin.autoImport.Revolver.enableDebugging(port = 5050))
lazy val scala3Version = "3.8.4"
lazy val commonSettings = Seq(
scalaVersion := scala3Version,
scalacOptions ++= Seq("-no-indent", "-Xmax-inlines", "64", "-explain-cyclic", "-Ydebug-cyclic"),
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.2.20" % Test,
"ch.qos.logback" % "logback-classic" % "1.6.1" % Test,
),
// scalafix settings
semanticdbEnabled := true, // enable SemanticDB
organization := "org.business4s",
homepage := Some(url("https://business4s.github.io/workflows4s/")),
licenses := List(License.MIT),
developers := List(
Developer(
"Krever",
"Voytek Pituła",
"w.pitula@gmail.com",
url("https://v.pitula.me"),
),
),
versionScheme := Some("semver-spec"),
Test / tpolecatExcludeOptions += ScalacOptions.warnNonUnitStatement,
)
lazy val pekkoVersion = "1.6.0"
lazy val pekkoHttpVersion = "1.4.0"
lazy val testcontainersScalaVersion = "0.44.1"
lazy val tapirVersion = "1.13.30"
lazy val circeVersion = "0.14.16"
addCommandAlias("prePR", List("compile", "Test / compile", "test", "scalafmtCheckAll").mkString(";", ";", ""))
lazy val stableVersion = taskKey[String]("stableVersion")
stableVersion := {
if (isVersionStable.value && !isSnapshot.value) version.value
else previousStableVersion.value.getOrElse("unreleased")
}
lazy val stableVersionFile = settingKey[File]("File that writeStableVersion writes to")
stableVersionFile := (ThisBuild / baseDirectory).value / "target" / "stable-version.txt"
// Writing to a file instead of printing, because sbt's stdout is not machine-readable
// (ANSI escapes, progress lines, launcher output). Consumed by the website build.
lazy val writeStableVersion = taskKey[Unit]("Writes stableVersion to stableVersionFile")
writeStableVersion := {
val target = stableVersionFile.value
IO.write(target, stableVersion.value)
streams.value.log.info(s"Wrote stable version to $target")
}
ThisBuild / publishTo := {
val centralSnapshots = "https://central.sonatype.com/repository/maven-snapshots/"
if (isSnapshot.value) Some("central-snapshots" at centralSnapshots)
else localStaging.value
}
Global / onChangedBuildSource := ReloadOnSourceChanges
// required for docker tags
ThisBuild / dynverSeparator := "-"