-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
303 lines (287 loc) · 14 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
import com.typesafe.sbt.packager.Keys.{ dockerBaseImage, dockerExposedPorts, dockerUpdateLatest, packageName }
import sbt.{ url, Resolver, ThisBuild }
import sbtrelease.ReleaseStateTransformations._
import java.nio.file.{ Files, Paths }
logLevel := Level.Debug
ThisBuild / organization := "eu.sia.pagopa"
ThisBuild / scalaVersion := "2.13.6"
ThisBuild / version := sys.props.getOrElse("buildNumber", "dev-SNAPSHOT")
lazy val akka = "2.6.16"
lazy val akkaTool = "1.1.1"
lazy val akkaHttp = "10.2.6"
lazy val logstash = "6.3"
lazy val logback = "1.2.3"
lazy val slick = "3.3.3"
lazy val mssqlJdbc = "7.0.0.jre8"
lazy val scalaXmlVersion = "1.3.0"
lazy val scalaParserCombinators = "1.1.2"
lazy val scalatest = "3.1.0"
lazy val scalamock = "5.1.0"
lazy val dispatch = "0.12.0"
lazy val bcpkixJdk15On = "1.69"
lazy val janalyseSsh = "0.10.4"
lazy val spotify = "8.16.0"
lazy val chill = "0.9.3"
lazy val scalaLogging = "3.9.2"
lazy val log4jOverSlf4j = "1.7.29"
lazy val commonsEmail = "1.5"
lazy val commonsIo = "2.6"
lazy val guava = "19.0"
lazy val freemarker = "2.3.29"
lazy val itext = "2.1.7"
lazy val opencsv = "2.3"
lazy val jaxbImpl = "2.1.13"
lazy val yamusca = "0.7.0"
lazy val scalai18n = "1.0.3"
lazy val playjson = "2.7.4"
lazy val scalazcore = "7.2.27"
lazy val jackson = "2.14.1"
lazy val galimatias = "0.2.1"
lazy val azuremessagingeventhubs = "5.9.0"
lazy val azuremessagingeventhubscheckpointstoreblob = "1.8.0"
lazy val scalaj = "2.4.2"
lazy val jaxbapi = "2.3.0"
lazy val micrometerRegistryPrometheus = "1.8.1"
lazy val micrometerJvmExtra = "0.2.2"
lazy val zerohash = "0.15"
lazy val pgversion = "42.5.0"
lazy val azureStorageBlob = "12.22.2"
lazy val azureStorageQueue = "12.18.0"
lazy val azureIdentity = "1.9.0"
val lightbendKey = sys.env.getOrElse("LIGHTBEND_KEY","5IDMAq0poMpRYz1HD58Y7c8jQ9kjlFs_yKCMkg3tdeBTeqiL")
ThisBuild / organization := "eu.sia.pagopa"
ThisBuild / scalaVersion := "2.13.6"
ThisBuild / versionScheme := Some("early-semver")
ThisBuild / resolvers += "lightbend-commercial-mvn" at s"https://repo.lightbend.com/pass/${lightbendKey}/commercial-releases"
ThisBuild / resolvers += Resolver.url("lightbend-commercial-ivy", url(s"https://repo.lightbend.com/pass/${lightbendKey}/commercial-releases"))(
Resolver.ivyStylePatterns
)
lazy val commonSettings: Seq[Def.Setting[_]] = Seq(
updateOptions := updateOptions.value.withGigahorse(false),
scalacOptions := Seq("-feature", "-unchecked", "-deprecation", "-encoding", "utf8"),
classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars,
Compile / run / fork := true,
Test / fork := true,
(Compile / packageBin) / publishArtifact := true,
(Compile / packageDoc) / publishArtifact := false,
(Compile / packageSrc) / publishArtifact := false
)
lazy val `pagopa-fdr`: Project = (project in file("."))
.aggregate(`common-xml`, `fdr`)
.settings(
commonSettings,
publish / skip := true,
update / aggregate := false,
jacocoAggregateReportSettings := JacocoReportSettings(title = "Flussi di rendicontazione", formats = Seq(JacocoReportFormats.ScalaHTML, JacocoReportFormats.XML)),
homepage := Some(url("https://github.com/pagopa/pagopa-fdr-nodo-dei-pagamenti")),
scmInfo := homepage.value.map(url => ScmInfo(url, "scm:[email protected]:pagopa/pagopa-fdr-nodo-dei-pagamenti.git")),
commands += Command.command("prepare-release")((state: State) => {
println("Preparing release...")
val extracted = Project extract state
val st = extracted.appendWithSession(
Seq(
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies, // : ReleaseStep
inquireVersions, // : ReleaseStep
runClean, // : ReleaseStep
runTest, // : ReleaseStep
setReleaseVersion, // : ReleaseStep
commitReleaseVersion // : ReleaseStep, performs the initial git checks
// tagRelease, // : ReleaseStep
// publishArtifacts, // : ReleaseStep, checks whether `publishTo` is properly set up
// setNextVersion, // : ReleaseStep
// commitNextVersion, // : ReleaseStep
// pushChanges // : ReleaseStep, also checks that an upstream branch is properly configured
)
),
state
)
Command.process("release with-defaults", st)
}),
commands += Command.command("complete-release")((state: State) => {
println("Preparing release...")
val extracted = Project extract state
var st = extracted.appendWithSession(
Seq(
releaseProcess := Seq[ReleaseStep](
// checkSnapshotDependencies, // : ReleaseStep
inquireVersions, // : ReleaseStep
// runClean, // : ReleaseStep
// runTest, // : ReleaseStep
// setReleaseVersion, // : ReleaseStep
// commitReleaseVersion, // : ReleaseStep, performs the initial git checks
// tagRelease, // : ReleaseStep
// publishArtifacts, // : ReleaseStep, checks whether `publishTo` is properly set up
setNextVersion, // : ReleaseStep
commitNextVersion, // : ReleaseStep
pushChanges // : ReleaseStep, also checks that an upstream branch is properly configured
)
),
state
)
Command.process("release with-defaults", st)
})
)
val `gen-xml-enum`: sbt.TaskKey[Unit] = taskKey[Unit]("gen-xml-enum")
lazy val `common-xml` = (project in file("common-xml"))
.enablePlugins(ScalaxbPlugin)
.settings(
commonSettings,
Scalaxb.scalaxbSettings,
libraryDependencies ++= {
Seq("javax.xml.bind" % "jaxb-api" % jaxbapi, "org.scala-lang.modules" %% "scala-xml" % scalaXmlVersion, "org.scala-lang.modules" %% "scala-parser-combinators" % scalaParserCombinators)
},
`gen-xml-enum` := {
println(s"########## generating xml classes ##########")
val srcMain = (Compile / baseDirectory).value / "src/main"
val file = (Compile / target).value / "wsdl-schema"
val srcMainPath = srcMain.getPath
val schemap = file.getPath
val schemaPath = Paths.get(schemap)
if (Files.exists(schemaPath)) {
new scala.reflect.io.Directory(new File(schemap)).deleteRecursively()
}
println(s"Create dirs: $schemaPath")
Files.createDirectories(schemaPath)
val toCopy = Map(
"2.0/wsdl/nodeForPa.wsdl" -> Seq("nodeforpa"),
"2.0/xsd/nodeForPa.xsd" -> Seq("nodeforpa"),
"2.0/wsdl/nodeForPsp.wsdl" -> Seq("nodeforpsp"),
"2.0/xsd/nodeForPsp.xsd" -> Seq("nodeforpsp"),
"2.0/xsd/sac-common-types-1.0.xsd" -> Seq("nodeforpsp", "nodeforpa"),
"2.0/xsd/FlussoRiversamento_1_0_4.xsd" -> Seq("flussoriversamento"),
"deprecated/general/IdRPT_128_AIM_v04.xsd" -> Seq("aim128", "nodoperpsp"),
"deprecated/general/IdRPT_GS1_128_v04.xsd" -> Seq("barcode", "nodoperpsp"),
"deprecated/general/IdRPT_QR_Code_v04.xsd" -> Seq("qrcode", "nodoperpsp"),
"deprecated/general/PagInf_RPT_RT_6_2_0.xsd" -> Seq("nodoperpsp", "paginf"),
"2.0/xsd/envelope.xsd" -> Seq("nodeforpa", "nodeforpsp", "nodoperpsp"),
"deprecated/general/sac-common-types-1.0.xsd" -> Seq("nodoperpsp", "paginf"),
"deprecated/nodo/NodoPerPsp.wsdl" -> Seq("nodoperpsp"),
"deprecated/nodo/NodoPerPa.wsdl" -> Seq("nodoperpa"),
"deprecated/general/envelope.xsd" -> Seq("nodoperpa"),
)
toCopy.foreach(tc => {
tc._2.foreach(dest => {
val destPath = Paths.get(s"$schemap/$dest")
if (!Files.exists(destPath)) {
println(s"creating dir ${destPath}")
Files.createDirectory(destPath)
} else {
println(s"exists dir ${destPath}")
}
println(s"copying $srcMainPath/${tc._1} to ${destPath / tc._1}")
Files.copy(Paths.get(s"$srcMainPath/${tc._1}"), destPath / tc._1.replaceAll(".*\\/", ""))
})
})
val sourcemanaged = (Compile / sourceManaged).value
val resourcemanaged = (Compile / resourceManaged).value
WsdlBuild.main(Array(sourcemanaged.getPath, resourcemanaged.getPath))
},
Compile / compile := ((Compile / compile) dependsOn `gen-xml-enum`).value,
Compile / sourceGenerators += (Def.task {
val file = (Compile / sourceManaged).value / "sbt-xsd" / "eu" / "sia" / "pagopa" / "commonxml"
if (file.exists()) {
file.listFiles().toSeq
} else Nil
} dependsOn `gen-xml-enum`).taskValue,
Compile / resourceGenerators += (Def.task {
val file = (Compile / resourceManaged).value / "xml-schema"
if (file.exists()) {
file.listFiles().flatMap(d => d.listFiles()).toSeq
} else Nil
} dependsOn `gen-xml-enum`).taskValue
)
import com.github.eikek.sbt.openapi.{ScalaConfig,CustomMapping,Pkg, TypeDef,Imports,Field}
lazy val `fdr` = (project in file("fdr"))
.dependsOn(`common-xml`)
.enablePlugins(Cinnamon, JavaAppPackaging, DockerPlugin, JavaAgent, OpenApiSchema)
.settings(
openapiTargetLanguage := Language.Scala,
openapiPackage := Pkg("it.pagopa.config"),
openapiScalaConfig := ScalaConfig()
.addMapping(CustomMapping.forType({
case TypeDef("LocalDateTime", _) =>
TypeDef("OffsetDateTime", Imports("java.time.OffsetDateTime"))
})).addMapping(CustomMapping.forType({
case TypeDef("Protocol", _) =>
TypeDef("String", Imports("java.lang.String"))
})).addMapping(CustomMapping.forField({
case Field(prop, annot, typeDef) if prop.name == "type" =>
Field(prop.copy(name = prop.name.mkString("`", "", "`")), annot, typeDef)
case Field(prop, annot, typeDef) if prop.name.contains("_") =>
val first = prop.name.substring(0,prop.name.indexOf("_"))
var tail = prop.name.substring(prop.name.indexOf("_")).split("_")
var newname = s"$first${tail.map(_.capitalize).mkString("")}"
val newname2 = s"""@com.fasterxml.jackson.annotation.JsonProperty("${prop.name}") ${newname}"""
Field(prop.copy(name = newname2), annot , typeDef)
})),
openapiSpec :=(Compile / resourceDirectory).value / "openapi_config.json",
commonSettings,
libraryDependencies += Cinnamon.library.cinnamonSlf4jMdc,
libraryDependencies += Cinnamon.library.cinnamonAkka,
libraryDependencies += Cinnamon.library.cinnamonPrometheus,
libraryDependencies += Cinnamon.library.cinnamonPrometheusHttpServer,
libraryDependencies += Cinnamon.library.cinnamonJvmMetricsProducer,
libraryDependencies += Cinnamon.library.cinnamonAkkaHttp,
libraryDependencies += Cinnamon.library.cinnamonJmxImporter,
libraryDependencies += Cinnamon.library.cinnamonHikariCPJmxImporter,
Test / javaOptions += s"-Duser.dir=${(ThisBuild / baseDirectory).value}/fdr/..",
run / cinnamon := true,
test / cinnamon := true,
cinnamonLogLevel := "INFO",
Compile / mainClass := Some("eu.sia.pagopa.Main"),
Docker / packageName := "nodo-dei-pagamenti",
dockerBaseImage := "adoptopenjdk:11-jdk-hotspot",
dockerExposedPorts := Seq(8080, 8558, 2552),
dockerUpdateLatest := true,
// dockerUsername := sys.props.get("docker.username"),
dockerRepository := sys.props.get("docker.registry"),
Compile / resourceDirectories += baseDirectory.value / "fe" / "build",
libraryDependencies ++= {
Seq(
"net.openhft" % "zero-allocation-hashing" % zerohash,
"com.typesafe.akka" %% "akka-actor" % akka,
"com.typesafe.akka" %% "akka-stream" % akka,
"com.typesafe.akka" %% "akka-slf4j" % akka,
"com.typesafe.akka" %% "akka-http" % akkaHttp,
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttp,
"com.lightbend.akka.management" %% "akka-management" % akkaTool,
"io.micrometer" % "micrometer-registry-prometheus" % micrometerRegistryPrometheus,
"io.github.mweirauch" % "micrometer-jvm-extras" % micrometerJvmExtra,
"com.github.eikek" %% "yamusca-core" % yamusca,
"net.logstash.logback" % "logstash-logback-encoder" % logstash,
"ch.qos.logback" % "logback-classic" % logback,
"com.typesafe.scala-logging" %% "scala-logging" % scalaLogging,
"org.slf4j" % "log4j-over-slf4j" % log4jOverSlf4j,
"com.typesafe.slick" %% "slick" % slick,
"com.typesafe.slick" %% "slick-hikaricp" % slick,
"org.bouncycastle" % "bcpkix-jdk15on" % bcpkixJdk15On,
"org.bouncycastle" % "bcprov-jdk15on" % bcpkixJdk15On,
"org.bouncycastle" % "bcutil-jdk15on" % bcpkixJdk15On,
"com.osinka.i18n" %% "scala-i18n" % scalai18n,
"com.typesafe.play" %% "play-json" % playjson,
"com.google.guava" % "guava" % guava,
"org.scalaz" %% "scalaz-core" % scalazcore,
"com.fasterxml.jackson.module" %% "jackson-module-scala" % jackson,
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % jackson,
"com.fasterxml.jackson.core" % "jackson-databind" % jackson,
"io.mola.galimatias" % "galimatias" % galimatias,
"fr.janalyse" %% "janalyse-ssh" % janalyseSsh,
"com.azure" % "azure-messaging-eventhubs" % azuremessagingeventhubs,
"com.azure" % "azure-messaging-eventhubs-checkpointstore-blob" % azuremessagingeventhubscheckpointstoreblob,
"com.azure" % "azure-storage-blob" % azureStorageBlob,
"com.azure" % "azure-storage-queue" % azureStorageQueue,
"com.azure" % "azure-identity" % azureIdentity,
"org.postgresql" % "postgresql" % pgversion,
"com.typesafe.akka" %% "akka-testkit" % akka % Test,
"org.scalatest" %% "scalatest" % scalatest % Test,
"org.scalaj" %% "scalaj-http" % scalaj % Test,
"com.h2database" % "h2" % "1.4.200" % Test,
"org.liquibase" % "liquibase-core" % "4.10.0" % Test,
"org.scala-lang.modules" %% "scala-xml" % scalaXmlVersion % Test,
"org.mockito" %% s"mockito-scala" % "1.17.30" % Test,
"com.softwaremill.sttp.client4" %% "core" % "4.0.0-M11" % Test,
"org.mock-server" % s"mockserver-netty" % "5.14.0" % Test
)
}
)