..
0 // *****************************************************************************
1 // Build settings
2 // *****************************************************************************
3
4 addCommandAlias("check", "Compile/scalafix --check; Test/scalafix --check; headerCheckAll; scalafmtCheckAll")
5 addCommandAlias("fix", "headerCreate; Compile/scalafix; Test/scalafix; scalafmtSbt; scalafmtAll")
6
7 // Enable the semanticdb compiler plugin needed by the metals language server.
8 Global / semanticdbEnabled := true
9
10 inThisBuild(
11 Seq(
12 scalaVersion := "3.3.3",
13 organization := "de.smederee",
14 organizationName := "Contributors as noted in the AUTHORS.md file",
15 version := "0.13.0-SNAPSHOT",
16 scalacOptions ++= Seq(
17 "-deprecation",
18 "-explain",
19 "-explain-types",
20 "-feature",
21 "-language:higherKinds",
22 "-language:implicitConversions",
23 "-no-indent", // Prevent usage of indent based syntax.
24 "-old-syntax", // Enforce classic syntax.
25 "-unchecked",
26 "-Wunused:imports", // Warn on unused imports including given and wildcard imports.
27 "-Wunused:linted", // TODO: Find out what this does!
28 "-Wunused:locals", // Warn on unused local definitions.
29 "-Wunused:nowarn", // Warn on unused (useless) `@nowarn` annotations.
30 "-Wunused:params", // Warn on unused parameters.
31 "-Wunused:privates", // Warn on unused private definitions.
32 "-Wunused:unsafe-warn-patvars", // TODO: Find out what this does!
33 "-Wvalue-discard", // Warn on discarding computed values.
34 // "-Xfatal-warnings", // FIXME: Make this work despite of Twirl!
35 "-Ykind-projector"
36 ),
37 resolvers += "jitpack" at "https://jitpack.io", // for JANSI fork
38 Compile / console / scalacOptions --= Seq("-Xfatal-warnings"),
39 Test / console / scalacOptions --= Seq("-Xfatal-warnings"),
40 Test / fork := true,
41 Test / parallelExecution := false,
42 Test / testOptions += Tests.Argument(TestFrameworks.MUnit, "-b")
43 )
44 )
45
46 // *****************************************************************************
47 // Projects
48 // *****************************************************************************
49
50 lazy val smederee =
51 project
52 .in(file("."))
53 .settings(commonSettings)
54 .settings(
55 name := "smederee",
56 publish := {},
57 publishLocal := {}
58 )
59 .aggregate(darcs, email, htmlUtils, hub, i18n, security, twirl)
60
61 lazy val darcs =
62 project
63 .in(file("modules/darcs"))
64 .enablePlugins(AutomateHeaderPlugin)
65 .settings(commonSettings)
66 .settings(
67 name := "darcs",
68 scalacOptions += "-Xfatal-warnings",
69 libraryDependencies ++= Seq(
70 library.catsCore,
71 library.catsEffect,
72 library.logback,
73 library.osLib,
74 library.munit % Test,
75 library.munitCatsEffect % Test,
76 library.munitScalaCheck % Test,
77 library.scalaCheck % Test
78 )
79 )
80
81 lazy val email =
82 project
83 .in(file("modules/email"))
84 .enablePlugins(AutomateHeaderPlugin)
85 .settings(commonSettings)
86 .settings(
87 name := "email",
88 scalacOptions += "-Xfatal-warnings",
89 libraryDependencies ++= Seq(
90 library.catsCore,
91 library.catsEffect,
92 library.ip4sCore,
93 library.logback,
94 library.simpleJavaMail,
95 library.munit % Test,
96 library.munitCatsEffect % Test,
97 library.munitScalaCheck % Test,
98 library.scalaCheck % Test
99 )
100 )
101
102 lazy val htmlUtils =
103 project
104 .in(file("modules/html-utils"))
105 .enablePlugins(AutomateHeaderPlugin)
106 .settings(commonSettings)
107 .settings(
108 name := "html-utils",
109 scalacOptions += "-Xfatal-warnings",
110 libraryDependencies ++= Seq(
111 library.catsCore,
112 library.commonMark,
113 library.commonMarkExtHeadingAnchor,
114 library.commonMarkExtImageAttrs,
115 library.commonMarkExtStrikethrough,
116 library.commonMarkExtTables,
117 library.commonMarkExtTaskListItems,
118 library.http4sCore,
119 library.ip4sCore,
120 library.logback,
121 library.munit % Test,
122 library.munitScalaCheck % Test,
123 library.scalaCheck % Test
124 )
125 )
126
127 lazy val hub =
128 project
129 .in(file("modules/hub"))
130 .dependsOn(darcs, email, htmlUtils, i18n, security, twirl)
131 .enablePlugins(
132 AutomateHeaderPlugin,
133 BuildInfoPlugin,
134 DebianPlugin,
135 JavaServerAppPackaging,
136 JDebPackaging,
137 RpmPlugin,
138 SbtTwirl,
139 SystemdPlugin
140 )
141 .settings(commonSettings)
142 .settings(
143 name := "smederee-hub",
144 buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion),
145 buildInfoPackage := "de.smederee.hub",
146 libraryDependencies ++= Seq(
147 library.apacheSshdCore,
148 library.apacheSshdSftp,
149 library.apacheSshdScp,
150 library.bouncyCastleProvider,
151 library.catsCore,
152 library.circeCore,
153 library.circeGeneric,
154 library.circeParser,
155 library.doobieCore,
156 library.doobieHikari,
157 library.doobiePostgres,
158 library.ed25519Java, // FIXME: Replace with BouncyCastle once implemented in Mina-SSHD!
159 library.flywayCore,
160 library.flywayPostgreSQL,
161 library.http4sCirce,
162 library.http4sCore,
163 library.http4sDsl,
164 library.http4sEmberClient,
165 library.http4sEmberServer,
166 // library.http4sTwirl,
167 library.jansi,
168 library.jclOverSlf4j, // Bridge Java Commons Logging to SLF4J.
169 library.log4catsSlf4j,
170 library.logback,
171 library.osLib,
172 library.postgresql,
173 library.pureConfig,
174 library.springSecurityCrypto,
175 library.munit % Test,
176 library.munitCatsEffect % Test,
177 library.munitScalaCheck % Test,
178 library.scalaCheck % Test
179 ),
180 TwirlKeys.templateImports ++= Seq(
181 "cats.*",
182 "cats.data.*",
183 "cats.syntax.all.*",
184 "de.smederee.html.*",
185 "de.smederee.i18n.*",
186 "de.smederee.security.{ CsrfToken, UserId, Username }",
187 "org.http4s.Uri"
188 )
189 )
190 .settings(
191 Seq(
192 daemonUser := "smederee",
193 daemonGroup := "smederee",
194 Debian / debianPackageProvides += "smederee-hub",
195 Debian / debianPackageDependencies += "openjdk-17-jre-headless",
196 defaultLinuxInstallLocation := "/usr/local/share",
197 maintainer := "Wegtam GmbH <devops@wegtam.com>",
198 rpmLicense := Option("AGPL-3.0 or later"),
199 rpmVendor := "Wegtam GmbH <devops@wegtam.com>",
200 // Require a service restart after installation / update.
201 Debian / maintainerScripts := maintainerScriptsAppend((Debian / maintainerScripts).value)(
202 DebianConstants.Postinst -> s"restartService ${normalizedName.value}"
203 ),
204 // Require a service restart after installation / update.
205 Rpm / maintainerScripts := maintainerScriptsAppend((Rpm / maintainerScripts).value)(
206 RpmConstants.Post -> s"restartService ${normalizedName.value}"
207 ),
208 packageSummary := "Smederee Hub Service - Software collaboration platform.",
209 packageDescription := "Leverage the power of the darcs vcs to handle your projects with ease and confidence, this is the central hub service",
210 // Debian / requiredStartFacilities := Option("$local_fs $remote_fs $network $postgresql"),
211 // Do not package API docs.
212 Compile / packageDoc / publishArtifact := false,
213 Compile / doc / sources := Seq.empty,
214 // Prevent a customised local application.conf file to be packaged!
215 Compile / packageBin / mappings ~= { files =>
216 files.filterNot { case (_, name) =>
217 name == "application.conf"
218 }
219 }
220 )
221 )
222
223 lazy val i18n =
224 project
225 .in(file("modules/i18n"))
226 .enablePlugins(AutomateHeaderPlugin)
227 .settings(commonSettings)
228 .settings(
229 name := "i18n",
230 scalacOptions += "-Xfatal-warnings",
231 libraryDependencies ++= Seq(
232 library.catsCore,
233 library.logback,
234 library.munit % Test,
235 library.munitScalaCheck % Test,
236 library.scalaCheck % Test
237 )
238 )
239
240 lazy val security =
241 project
242 .in(file("modules/security"))
243 .enablePlugins(AutomateHeaderPlugin)
244 .settings(commonSettings)
245 .settings(
246 name := "security",
247 scalacOptions += "-Xfatal-warnings",
248 libraryDependencies ++= Seq(
249 library.bouncyCastleProvider % Runtime,
250 library.catsCore,
251 library.jclOverSlf4j, // Bridge Java Commons Logging to SLF4J.
252 library.logback,
253 library.springSecurityCrypto,
254 library.munit % Test,
255 library.munitScalaCheck % Test,
256 library.scalaCheck % Test
257 )
258 )
259
260 // FIXME: This is a workaround until http4s-twirl gets published properly for Scala 3!
261 lazy val twirl =
262 project
263 .in(file("twirl"))
264 .enablePlugins(SbtTwirl)
265 .settings(commonSettings)
266 .settings(
267 name := "twirl",
268 version := "0.1.0",
269 libraryDependencies += library.http4sCore
270 )
271
272 // *****************************************************************************
273 // Library dependencies
274 // *****************************************************************************
275
276 lazy val library =
277 new {
278 object Version {
279 val apacheSshd = "2.12.1"
280 val bouncyCastle = "1.78.1"
281 val cats = "2.10.0"
282 val catsEffect = "3.5.4"
283 val circe = "0.14.6"
284 val commonMark = "0.22.0"
285 val doobie = "1.0.0-RC5"
286 val flyway = "10.11.1"
287 val fs2 = "3.5.0"
288 val http4s = "1.0.0-M41"
289 val ip4s = "3.5.0"
290 val jansi = "2.4.2"
291 val jclOverSlf4j = "2.0.13"
292 val log4cats = "2.6.0"
293 val logback = "1.5.6"
294 val munit = "1.0.0-M12"
295 val munitCatsEffect = "2.0.0-M5"
296 val osLib = "0.10.0"
297 val postgresql = "42.7.3"
298 val pureConfig = "0.17.6"
299 val scalaCheck = "1.18.0"
300 val simpleJavaMail = "8.8.4"
301 val springSecurity = "6.2.4"
302 }
303 val apacheSshdCore = "org.apache.sshd" % "sshd-core" % Version.apacheSshd
304 val apacheSshdSftp = "org.apache.sshd" % "sshd-sftp" % Version.apacheSshd
305 val apacheSshdScp = "org.apache.sshd" % "sshd-scp" % Version.apacheSshd
306 val bouncyCastleProvider = "org.bouncycastle" % "bcprov-jdk15to18" % Version.bouncyCastle
307 val catsCore = "org.typelevel" %% "cats-core" % Version.cats
308 val catsEffect = "org.typelevel" %% "cats-effect" % Version.catsEffect
309 val circeCore = "io.circe" %% "circe-core" % Version.circe
310 val circeGeneric = "io.circe" %% "circe-generic" % Version.circe
311 val circeParser = "io.circe" %% "circe-parser" % Version.circe
312 val commonMark = "org.commonmark" % "commonmark" % Version.commonMark
313 val commonMarkExtHeadingAnchor = "org.commonmark" % "commonmark-ext-heading-anchor" % Version.commonMark
314 val commonMarkExtImageAttrs = "org.commonmark" % "commonmark-ext-image-attributes" % Version.commonMark
315 val commonMarkExtStrikethrough = "org.commonmark" % "commonmark-ext-gfm-strikethrough" % Version.commonMark
316 val commonMarkExtTables = "org.commonmark" % "commonmark-ext-gfm-tables" % Version.commonMark
317 val commonMarkExtTaskListItems = "org.commonmark" % "commonmark-ext-task-list-items" % Version.commonMark
318 val doobieCore = "org.tpolecat" %% "doobie-core" % Version.doobie
319 val doobieHikari = "org.tpolecat" %% "doobie-hikari" % Version.doobie
320 val doobiePostgres = "org.tpolecat" %% "doobie-postgres" % Version.doobie
321 val doobieScalaTest = "org.tpolecat" %% "doobie-scalatest" % Version.doobie
322 val ed25519Java = "net.i2p.crypto" % "eddsa" % "0.3.0"
323 val flywayCore = "org.flywaydb" % "flyway-core" % Version.flyway
324 val flywayPostgreSQL = "org.flywaydb" % "flyway-database-postgresql" % Version.flyway
325 val fs2Core = "co.fs2" %% "fs2-core" % Version.fs2
326 val fs2IO = "co.fs2" %% "fs2-io" % Version.fs2
327 val http4sCirce = "org.http4s" %% "http4s-circe" % Version.http4s
328 val http4sCore = "org.http4s" %% "http4s-core" % Version.http4s
329 val http4sDsl = "org.http4s" %% "http4s-dsl" % Version.http4s
330 val http4sEmberServer = "org.http4s" %% "http4s-ember-server" % Version.http4s
331 val http4sEmberClient = "org.http4s" %% "http4s-ember-client" % Version.http4s
332 val ip4sCore = "com.comcast" %% "ip4s-core" % Version.ip4s
333 val jansi = "com.github.Osiris-Team" % "jansi" % Version.jansi
334 val jclOverSlf4j = "org.slf4j" % "jcl-over-slf4j" % Version.jclOverSlf4j
335 val log4catsSlf4j = "org.typelevel" %% "log4cats-slf4j" % Version.log4cats
336 val logback = "ch.qos.logback" % "logback-classic" % Version.logback
337 val munit = "org.scalameta" %% "munit" % Version.munit
338 val munitCatsEffect = "org.typelevel" %% "munit-cats-effect" % Version.munitCatsEffect
339 val munitScalaCheck = "org.scalameta" %% "munit-scalacheck" % Version.munit
340 val osLib = "com.lihaoyi" %% "os-lib" % Version.osLib
341 val postgresql = "org.postgresql" % "postgresql" % Version.postgresql
342 val pureConfig = "com.github.pureconfig" %% "pureconfig-core" % Version.pureConfig
343 val scalaCheck = "org.scalacheck" %% "scalacheck" % Version.scalaCheck
344 val simpleJavaMail = "org.simplejavamail" % "simple-java-mail" % Version.simpleJavaMail
345 val springSecurityCrypto = "org.springframework.security" % "spring-security-crypto" % Version.springSecurity
346 }
347
348 // *****************************************************************************
349 // Settings
350 // *****************************************************************************
351
352 lazy val commonSettings =
353 codeSettings ++
354 scalafmtSettings
355
356 lazy val codeSettings =
357 Seq(
358 startYear := Option(2022),
359 licenses += ("AGPL-3.0-or-later", new URI("https://www.gnu.org/licenses/agpl-3.0.txt").toURL())
360 )
361
362 lazy val scalafmtSettings =
363 Seq(
364 scalafmtOnCompile := false
365 )