-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.sbt
207 lines (181 loc) · 11.6 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
scalaVersion := "2.13.15"
enablePlugins(JavaServerAppPackaging)
enablePlugins(DockerPlugin)
enablePlugins(AshScriptPlugin)
name := "openolitor-server"
mainClass := Some("ch.openolitor.core.Boot")
Compile / mainClass := Some("ch.openolitor.core.Boot")
assembly / assemblyJarName := "openolitor-server.jar"
assembly / assemblyMergeStrategy := {
case PathList("org", "slf4j", xs @ _*) => MergeStrategy.first
case "library.properties" => MergeStrategy.discard
case x =>
val oldStrategy = (assembly / assemblyMergeStrategy).value
oldStrategy(x)
}
import scalariform.formatter.preferences._
import com.typesafe.sbt.SbtScalariform
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
import com.typesafe.sbt.packager.docker.Cmd
import java.text.SimpleDateFormat
import java.util.Calendar
val specs2V = "4.20.9" // based on spray 1.3.x built in support
val akkaV = "2.7.+"
val sprayV = "1.3.+"
val scalalikeV = "4.3.2"
val akkaHttpVersion = "10.5.3"
val akkaVersion = "2.8.5"
val testContainersVersion = "1.20.4"
resolvers += Resolver.typesafeRepo("releases")
val buildSettings = Seq(
scalariformPreferences := scalariformPreferences.value
.setPreference(DanglingCloseParenthesis, Force)
.setPreference(AlignSingleLineCaseStatements, true),
version := "2.6.42",
scalaVersion := "2.13.15",
crossScalaVersions := Seq("2.13.8", "2.13.13"),
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
resolvers ++= Resolver.sonatypeOssRepos("releases"),
resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/",
// add -Xcheckinit to scalac options to check for null val's during initialization see also:
// https://docs.scala-lang.org/tutorials/FAQ/initialization-order.html
scalacOptions ++= Seq("-unchecked", "-deprecation", "-encoding", "utf8", "-feature", "-language:_", "-language:postfixOps"),
libraryDependencies ++= {
Seq(
"org.scala-lang.modules" %% "scala-xml" % "2.3.0",
"javax.xml.bind" % "jaxb-api" % "2.3.1",
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-caching" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion, // ### NO Scala 3
"com.typesafe.akka" %% "akka-actor" % akkaVersion,
"com.typesafe.akka" %% "akka-persistence" % akkaVersion,
"com.typesafe.akka" %% "akka-persistence-query" % akkaVersion,
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion,
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % "test",
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % "test",
"com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion % "test",
"com.lightbend.akka" %% "akka-persistence-jdbc" % "5.0.4",
"com.github.dnvriend" %% "akka-persistence-inmemory" % "2.5.15.2" % "test", // ### NO Scala 3
"org.specs2" %% "specs2-core" % specs2V % "test", // ### Scala 3
"org.specs2" %% "specs2-mock" % specs2V % "test",
"org.specs2" %% "specs2-junit" % specs2V % "test",
"org.specs2" %% "specs2-scalacheck" % specs2V % "test",
"org.mockito" %% "mockito-scala" % "1.17.37" % "test",
"org.scalaz" %% "scalaz-core" % "7.3.6", // ### Scala 3
//use scala logging to log outside of the actor system
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5", // ### Scala 3
"org.scalikejdbc" %% "scalikejdbc-async" % "0.20.0",
"org.scalikejdbc" %% "scalikejdbc-config" % scalalikeV, // ### Scala 3
"org.scalikejdbc" %% "scalikejdbc-test" % scalalikeV % "test", // ### Scala 3
"org.scalikejdbc" %% "scalikejdbc-syntax-support-macro" % scalalikeV, // ### Scala 3
"org.scalikejdbc" %% "scalikejdbc-joda-time" % scalalikeV, // ### Scala 3
"com.github.jasync-sql" % "jasync-mysql" % "2.2.+",
"com.h2database" % "h2" % "2.3.232" % "test",
"org.testcontainers" % "mariadb" % testContainersVersion % "test",
"io.findify" %% "s3mock" % "0.2.6" % "test",
"ch.qos.logback" % "logback-classic" % "1.5.12",
"org.mariadb.jdbc" % "mariadb-java-client" % "3.5.1",
"com.mysql" % "mysql-connector-j" % "9.1.0",
// Libreoffice document API
"org.odftoolkit" % "simple-odf" % "0.9.0" withSources(),
"com.scalapenos" %% "stamina-json" % "0.1.6", // ### NO Scala 3
"net.virtual-void" %% "json-lenses" % "0.6.2",
// s3
"com.amazonaws" % "aws-java-sdk-s3" % "1.12.779",
"de.svenkubiak" % "jBCrypt" % "0.4.1",
"com.github.daddykotex" %% "courier" % "3.2.0", // ### Scala 3
"com.github.nscala-time" %% "nscala-time" % "2.34.0", // ### Scala 3
"com.github.blemale" %% "scaffeine" % "5.3.0", // ### Scala 3
"de.zalando" %% "beard" % "0.3.3" exclude("ch.qos.logback", "logback-classic") from "https://github.com/OpenOlitor/beard/releases/download/0.3.3/beard_2.13-0.3.3.jar", // ### NO Scala 3, NO Scala 2.13
// transitive dependencies of legacy de.zalando.beard
"org.antlr" % "antlr4" % "4.8-1",
"io.monix" %% "monix" % "3.4.1", // ### Scala 3
"net.codecrete.qrbill" % "qrbill-generator" % "3.2.0",
"io.nayuki" % "qrcodegen" % "1.8.0",
"org.apache.pdfbox" % "pdfbox" % "2.0.32",
"org.apache.pdfbox" % "pdfbox-parent" % "2.0.32" pomOnly(),
"org.apache.xmlgraphics" % "batik-transcoder" % "1.18",
"org.apache.xmlgraphics" % "batik-codec" % "1.18",
"com.tegonal" %% "cf-env-config-loader" % "1.1.2", // ### NO Scala 3, NO Scala 2.13
"com.eatthepath" % "java-otp" % "0.4.0",
"org.apache.pdfbox" % "pdfbox-tools" % "2.0.32"
)
},
dependencyOverrides ++= Seq(
"org.scala-lang.modules" %% "scala-parser-combinators" % "2.4.0",
"xerces" % "xercesImpl" % "2.12.2",
"org.apache.commons" % "commons-compress" % "1.26.2",
"io.netty" % "netty-handler" % "4.1.115.Final",
"org.apache.jena" % "jena-core" % "5.2.0",
"com.google.protobuf" % "protobuf-java" % "4.29.0",
"com.google.guava" % "guava" % "33.0.0-jre"
)
)
lazy val scalaxbSettings = Seq(
Compile / scalaxb / scalaxbXsdSource := baseDirectory.value / "src" / "main" / "resources" / "xsd",
Compile / scalaxb / scalaxbPackageName := "ch.openolitor.generated.xsd",
Compile / scalaxb / scalaxbPackageNames := Map(uri("urn:iso:std:iso:20022:tech:xsd:camt.054.001.06") -> "ch.openolitor.generated.xsd.camt054_001_06",
uri("urn:iso:std:iso:20022:tech:xsd:camt.054.001.04") -> "ch.openolitor.generated.xsd.camt054_001_04",
uri("urn:iso:std:iso:20022:tech:xsd:pain.008.001.07") -> "ch.openolitor.generated.xsd.pain008_001_07",
uri("urn:iso:std:iso:20022:tech:xsd:pain.008.001.02") -> "ch.openolitor.generated.xsd.pain008_001_02")
)
lazy val macroSub = (project in file("macro")).settings(buildSettings,
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value)
lazy val coverageSettings = Seq(
coverageExcludedPackages := "$:;<empty>;ch.openolitor.core.Boot;.*Default.*;scalaxb.*;ch.openolitor.generated.*;ch.openolitor.core.scalax.*;ch.openolitor.core.repositories.Parameters*"
)
lazy val testSettings = Seq(
Test / parallelExecution := true,
Test / fork := true,
Test / testForkedParallel := true,
testOptions += Tests.Argument("timefactor", "5"),
Test / javaOptions ++= Seq(
"-Dconfig.resource=application-test.conf"
)
)
lazy val main = (project in file(".")).enablePlugins(sbtscalaxb.ScalaxbPlugin).settings(buildSettings ++ scalaxbSettings ++ coverageSettings ++ testSettings ++ Seq(
Compile / sourceGenerators += task[Seq[File]]{
val dir = (Compile / sourceManaged).value
val maxParams = 30
val mappings = (1 to maxParams).map{ n =>
val file = dir / "openolitor" / "ch" / "openolitor" / "core" / "repositories" / s"Parameters${n}.scala"
IO.write(file, GenerateParametersMapping(n))
file
}
val paramsTrait = {
val file = dir / "openolitor" / "ch" / "openolitor" / "core" / "repositories" / s"Parameters.scala"
IO.write(file, GenerateParametersTrait(maxParams))
file
}
val tuples = (23 to maxParams).map{ n =>
val file = dir / "openolitor" / "ch" / "openolitor" / "core" / "scalax" / s"Tuple${n}.scala"
IO.write(file, GenerateTuples(n))
file
}
mappings ++ tuples :+ paramsTrait
},
Compile / packageSrc / mappings ++= (Compile / managedSources).value.map{ f =>
// to merge generated sources into sources.jar as well
(f, f.relativeTo((Compile / sourceManaged).value).get.getPath)
}
)) dependsOn (macroSub)
lazy val root = (project in file("root")).settings(buildSettings).aggregate(macroSub, main)
dockerUsername := Some("openolitor")
val updateLatest = sys.env.get("DOCKER_UPDATE_LATEST") match {
case Some("true") =>
true
case _ =>
false
}
dockerUpdateLatest := updateLatest
dockerBaseImage := "eclipse-temurin:21-alpine"
dockerExposedPorts ++= Seq(9003)
// the directories created, e.g. /var/log/openolitor-server, are created using user id 1000,
// but the default user starting the app has id 1001 which wouldn't have access to it
Docker / daemonUserUid := Some("1000")
val todayD = Calendar.getInstance.getTime
val today = new SimpleDateFormat("yyyyMMdd").format(todayD)
dockerEnvVars := Map("application_buildnr" -> today)
Docker / maintainer := "OpenOlitor Team <info@openolitor.org>"
Docker / version := sys.env.get("GITHUB_REF").getOrElse(version.value + "_SNAPSHOT").split("/").last