-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sbt
195 lines (160 loc) · 8.54 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
import ProjectSettings.ProjectFrom
import com.typesafe.sbt.packager.docker.Cmd
ThisBuild / scalaVersion := "2.13.8"
ThisBuild / organization := "it.pagopa"
ThisBuild / organizationName := "Pagopa S.p.A."
ThisBuild / libraryDependencies := Dependencies.Jars.`server`
Global / onChangedBuildSource := ReloadOnSourceChanges
ThisBuild / version := ComputeVersion.version
ThisBuild / githubOwner := "pagopa"
ThisBuild / githubRepository := "interop-be-party-process"
ThisBuild / resolvers += Resolver.githubPackages("pagopa")
ThisBuild / resolvers += "cefdigital" at s"https://ec.europa.eu/cefdigital/artifact/content/repositories/esignaturedss"
ThisBuild / resolvers += "selfcare" at s"https://pkgs.dev.azure.com/pagopaspa/selfcare-platform-app-projects/_packaging/selfcare-platform/maven/v1"
lazy val generateCode = taskKey[Unit]("A task for generating the code starting from the swagger definition")
val packagePrefix = settingKey[String]("The package prefix derived from the uservice name")
packagePrefix := name.value
.replaceFirst("interop-", "interop.")
.replaceFirst("be-", "")
.replaceAll("-", "")
val projectName = settingKey[String]("The project name prefix derived from the uservice name")
projectName := name.value
.replaceFirst("interop-", "")
.replaceFirst("be-", "")
generateCode := {
import sys.process._
val openApiCommand: String = {
if (System.getProperty("os.name").toLowerCase.contains("win")) "openapi-generator-cli-win.bat"
else "openapi-generator-cli"
}
Process(s"""$openApiCommand generate -t template/scala-akka-http-server
| -i src/main/resources/interface-specification.yml
| -g scala-akka-http-server
| -p projectName=${projectName.value}
| -p invokerPackage=it.pagopa.${packagePrefix.value}.server
| -p modelPackage=it.pagopa.${packagePrefix.value}.model
| -p apiPackage=it.pagopa.${packagePrefix.value}.api
| -p dateLibrary=java8
| -p entityStrictnessTimeout=15
| -o generated""".stripMargin).!!
Process(s"""$openApiCommand generate -t template/scala-akka-http-client
| -i src/main/resources/interface-specification.yml
| -g scala-akka
| -p projectName=${projectName.value}
| -p invokerPackage=it.pagopa.${packagePrefix.value}.client.invoker
| -p modelPackage=it.pagopa.${packagePrefix.value}.client.model
| -p apiPackage=it.pagopa.${packagePrefix.value}.client.api
| -p dateLibrary=java8
| -o client""".stripMargin).!!
Process(s"""$openApiCommand generate -t template/scala-akka-http-client
| -i userreg/api-docs.json
| -g scala-akka
| -p projectName=userreg
| -p invokerPackage=it.pagopa.userreg.client.invoker
| -p modelPackage=it.pagopa.userreg.client.model
| -p apiPackage=it.pagopa.userreg.client.api
| -p dateLibrary=java8
| -o userreg""".stripMargin).!!
Process(s"""$openApiCommand generate -t template/scala-akka-http-client
| -i product/api-docs.json
| -g scala-akka
| -p projectName=product
| -p invokerPackage=it.pagopa.product.client.invoker
| -p modelPackage=it.pagopa.product.client.model
| -p apiPackage=it.pagopa.product.client.api
| -p dateLibrary=java8
| -o product""".stripMargin).!!
Process(s"""$openApiCommand generate -t template/scala-akka-http-client
| -i geo-taxonomy/api-docs.json
| -g scala-akka
| -p projectName=geoTaxonomy
| -p invokerPackage=it.pagopa.geotaxonomy.client.invoker
| -p modelPackage=it.pagopa.geotaxonomy.client.model
| -p apiPackage=it.pagopa.geotaxonomy.client.api
| -p dateLibrary=java8
| -o geo-taxonomy""".stripMargin).!!
}
val runStandalone = inputKey[Unit]("Run the app using standalone configuration")
runStandalone := {
task(System.setProperty("config.file", "src/main/resources/application-standalone.conf")).value
(Compile / run).evaluated
}
(Compile / compile) := ((Compile / compile) dependsOn generateCode).value
(Test / test) := ((Test / test) dependsOn generateCode).value
cleanFiles += baseDirectory.value / "generated" / "src"
cleanFiles += baseDirectory.value / "generated" / "target"
cleanFiles += baseDirectory.value / "client" / "src"
cleanFiles += baseDirectory.value / "client" / "target"
cleanFiles += baseDirectory.value / "userreg" / "src"
cleanFiles += baseDirectory.value / "userreg" / "target"
cleanFiles += baseDirectory.value / "product" / "src"
cleanFiles += baseDirectory.value / "product" / "target"
cleanFiles += baseDirectory.value / "geo-taxonomy" / "src"
cleanFiles += baseDirectory.value / "geo-taxonomy" / "target"
lazy val generated = project
.in(file("generated"))
.settings(scalacOptions := Seq())
.setupBuildInfo
lazy val client = project
.in(file("client"))
.settings(
name := "interop-be-party-process-client",
scalacOptions := Seq(),
scalafmtOnCompile := true,
libraryDependencies := Dependencies.Jars.client,
updateOptions := updateOptions.value.withGigahorse(false),
Docker / publish := {}
)
lazy val userreg = project
.in(file("userreg"))
.settings(
name := "userreg",
scalacOptions := Seq(),
scalafmtOnCompile := true,
libraryDependencies := Dependencies.Jars.client,
updateOptions := updateOptions.value.withGigahorse(false)
)
lazy val product = project
.in(file("product"))
.settings(
name := "product",
scalacOptions := Seq(),
scalafmtOnCompile := true,
libraryDependencies := Dependencies.Jars.client,
updateOptions := updateOptions.value.withGigahorse(false)
)
lazy val geoTaxonomy = project
.in(file("geo-taxonomy"))
.settings(
name := "geoTaxonomy",
scalacOptions := Seq(),
scalafmtOnCompile := true,
libraryDependencies := Dependencies.Jars.client,
updateOptions := updateOptions.value.withGigahorse(false)
)
lazy val root = (project in file("."))
.settings(
name := "interop-be-party-process",
Test / parallelExecution := false,
scalafmtOnCompile := true,
dockerBuildOptions ++= Seq("--network=host"),
dockerRepository := Some(System.getenv("DOCKER_REPO")),
dockerBaseImage := "adoptopenjdk:11-jdk-hotspot",
daemonUser := "daemon",
Docker / version := (ThisBuild / version).value.replaceAll("-SNAPSHOT", "-latest").toLowerCase,
Docker / packageName := s"${name.value}",
Docker / dockerExposedPorts := Seq(8080),
Docker / maintainer := "https://pagopa.it",
dockerCommands += Cmd("LABEL", s"org.opencontainers.image.source https://github.com/pagopa/${name.value}")
)
.aggregate(client)
.dependsOn(generated)
.dependsOn(userreg)
.dependsOn(product)
.dependsOn(geoTaxonomy)
.enablePlugins(JavaAppPackaging, JavaAgent)
.setupBuildInfo
javaAgents += "io.kamon" % "kanela-agent" % "1.0.14"
Test / fork := true
Test / javaOptions += "-Dconfig.file=src/test/resources/application-test.conf"
Test / parallelExecution := false