This repository has been archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sbt
104 lines (86 loc) · 4.16 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
import ProjectSettings.ProjectFrom
ThisBuild / scalaVersion := "2.13.7"
ThisBuild / organization := "it.pagopa"
ThisBuild / organizationName := "Pagopa S.p.A."
ThisBuild / libraryDependencies := Dependencies.Jars.`server`
ThisBuild / dependencyOverrides ++= Dependencies.Jars.overrides
ThisBuild / version := ComputeVersion.version
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("pdnd-", "pdnd.").replaceFirst("uservice-", "uservice.").replaceAll("-", "")
}
generateCode := {
import sys.process._
Process(s"""openapi-generator-cli generate -t template/scala-akka-http-server
| -i src/main/resources/interface-specification.yml
| -g scala-akka-http-server
| -p projectName=${name.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"""openapi-generator-cli generate -t template/scala-akka-http-client
| -i src/main/resources/interface-specification.yml
| -g scala-akka
| -p projectName=${name.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).!!
}
Compile / PB.targets := Seq(scalapb.gen() -> (Compile / sourceManaged).value / "protobuf")
cleanFiles += baseDirectory.value / "generated" / "src"
cleanFiles += baseDirectory.value / "generated" / "target"
cleanFiles += baseDirectory.value / "client" / "src"
cleanFiles += baseDirectory.value / "client" / "target"
lazy val generated = project
.in(file("generated"))
.settings(
scalacOptions := Seq()
).setupBuildInfo
lazy val client = project
.in(file("client"))
.settings(
name := "pdnd-uservice-rest-template-client",
scalacOptions := Seq(),
libraryDependencies := Dependencies.Jars.client,
credentials += Credentials(Path.userHome / ".sbt" / ".credentials"),
updateOptions := updateOptions.value.withGigahorse(false),
publishTo := {
val nexus = s"https://${System.getenv("MAVEN_REPO")}/nexus/repository/"
if (isSnapshot.value)
Some("snapshots" at nexus + "maven-snapshots/")
else
Some("releases" at nexus + "maven-releases/")
}
)
lazy val root = (project in file("."))
.settings(
name := "pdnd-uservice-rest-template",
Test / parallelExecution := false,
dockerBuildOptions ++= Seq("--network=host"),
dockerRepository := Some(System.getenv("DOCKER_REPO")),
dockerBaseImage := "adoptopenjdk:11-jdk-hotspot",
dockerUpdateLatest := true,
daemonUser := "daemon",
Docker / version := s"${
val buildVersion = (ThisBuild / version).value
if (buildVersion == "latest")
buildVersion
else
s"v$buildVersion"
}".toLowerCase,
Docker / packageName := s"services/${name.value}",
Docker / dockerExposedPorts := Seq(8080),
Compile / compile / wartremoverErrors ++= Warts.all,
wartremoverExcluded += sourceManaged.value
)
.aggregate(client)
.dependsOn(generated)
.enablePlugins(JavaAppPackaging, JavaAgent)
.setupBuildInfo
javaAgents += "io.kamon" % "kanela-agent" % "1.0.13"