-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sbt
216 lines (202 loc) · 6.89 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
import sbt.url
import sbtghactions.GenerativePlugin.autoImport.{
githubWorkflowPublish,
githubWorkflowPublishTargetBranches,
JavaSpec
}
import scala.collection.Seq
import xerial.sbt.Sonatype.sonatypeCentralHost
import Dependencies.versions
addCommandAlias("fmt", "scalafmtAll; scalafmtSbt; mock_server/scalafmtAll")
addCommandAlias("it", "integration_test/test")
addCommandAlias("compileAll", "+compile; integration_test/test:compile; mock_server/compile")
addCommandAlias(
"mimaChecks",
"core/mimaReportBinaryIssues; requests/mimaReportBinaryIssues; sttp_core/mimaReportBinaryIssues; upickle/mimaReportBinaryIssues; zio_json/mimaReportBinaryIssues"
)
val globals = new {
val projectName = "sonatype-central-client"
val organizationName = "com.lumidion"
}
lazy val crossScalaVersionsGlobal = Seq(versions.scala212, versions.scala213, versions.scala3)
inThisBuild(
List(
name := globals.projectName,
organization := globals.organizationName,
homepage := Some(url("https://github.com/lumidion/sonatype-central-client")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
id = "andrapyre",
name = "David Doyle",
email = "[email protected]",
url = url("https://www.lumidion.com/about")
)
),
scalacOptions ++= Seq("-feature"),
versionScheme := Some("semver-spec"),
sonatypeCredentialHost := sonatypeCentralHost,
githubWorkflowJavaVersions := Seq(
JavaSpec.temurin("11")
),
githubWorkflowScalaVersions := crossScalaVersionsGlobal,
githubWorkflowAddedJobs ++= Seq(
WorkflowJob(
id = "mima_check",
name = "Mima Check",
steps = List(
WorkflowStep.Use(UseRef.Public("actions", "checkout", "v4"), Map("fetch-depth" -> "0")),
WorkflowStep.Use(UseRef.Public("coursier", "setup-action", "v1"))
) ++ WorkflowStep.SetupJava(List(JavaSpec.temurin("21"))) ++ List(
WorkflowStep.Use(UseRef.Public("sbt", "setup-sbt", "v1")),
WorkflowStep.Sbt(List("mimaChecks"))
),
cond = Option("${{ github.event_name == 'pull_request' }}"),
javas = List(JavaSpec.temurin("21"))
),
WorkflowJob(
"check",
"Check Formatting",
List(
WorkflowStep.Use(UseRef.Public("actions", "checkout", "v4"), Map("fetch-depth" -> "0")),
WorkflowStep.Use(UseRef.Public("coursier", "setup-action", "v1")),
WorkflowStep.Use(UseRef.Public("sbt", "setup-sbt", "v1")),
WorkflowStep.Sbt(
name = Some("Check Formatting"),
commands = List(s"scalafmtCheckAll")
)
),
javas = List(
JavaSpec.temurin("11")
),
cond = Option("${{ github.event_name == 'pull_request' }}")
)
),
githubWorkflowIncludeClean := false,
githubWorkflowArtifactUpload := false,
githubWorkflowTargetTags ++= Seq("v*"),
githubWorkflowPublishTargetBranches :=
Seq(RefPredicate.StartsWith(Ref.Tag("v"))),
githubWorkflowBuild := Seq(
WorkflowStep
.Sbt(
name = Some("Build"),
commands = List("clean", "compile", "integration_test/test:compile")
),
WorkflowStep.Run(name = Some("Start Mock Server"), commands = List("./start-mock-server.sh")),
WorkflowStep.Sbt(name = Some("Run Integration Tests"), commands = List("it"))
),
githubWorkflowTargetBranches := Seq("main"),
githubWorkflowPublish := Seq(
WorkflowStep.Sbt(
commands = List("ci-release"),
name = Some("Publish project"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"
)
)
)
)
)
val mimaSettings = Seq(
mimaPreviousArtifacts ++= previousStableVersion.value
.map(organization.value %% name.value % _)
.toSet
)
val commonSettings = Seq(
crossScalaVersions := crossScalaVersionsGlobal,
scalacOptions ++= {
if (scalaVersion.value == versions.scala3) {
Seq(
"-Werror",
"-Wunused:all",
"-deprecation"
)
} else Seq.empty
}
)
lazy val core = (project in file("modules/core"))
.settings(
name := s"${globals.projectName}-core"
)
.settings(mimaSettings)
.settings(commonSettings)
lazy val requests = (project in file("modules/requests"))
.settings(
name := s"${globals.projectName}-requests",
libraryDependencies ++= Seq(
"com.lihaoyi" %% "requests" % versions.requests
)
)
.settings(mimaSettings)
.settings(commonSettings)
.dependsOn(core, upickle)
lazy val sttp_core = (project in file("modules/sttp-core"))
.settings(
name := s"${globals.projectName}-sttp-core",
libraryDependencies ++= Seq(
"com.softwaremill.sttp.client4" %% "core" % versions.sttp
)
)
.settings(mimaSettings)
.settings(commonSettings)
.dependsOn(core)
lazy val upickle = (project in file("modules/upickle"))
.settings(
name := s"${globals.projectName}-upickle",
libraryDependencies ++= Seq(
"com.lihaoyi" %% "upickle" % versions.upickle
)
)
.settings(mimaSettings)
.settings(commonSettings)
.dependsOn(core)
lazy val zio_json = (project in file("modules/zio-json"))
.settings(
name := s"${globals.projectName}-zio-json",
libraryDependencies ++= Seq(
"dev.zio" %% "zio-json" % versions.zioJson
)
)
.settings(mimaSettings)
.settings(commonSettings)
.dependsOn(sttp_core)
lazy val integration_test = (project in file("modules/integration-test"))
.settings(
publish / skip := true,
name := "it",
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % versions.scalatest % Test,
"com.softwaremill.sttp.client4" %% "zio-json" % versions.sttp % Test
)
)
.settings(commonSettings)
.dependsOn(requests, sttp_core, zio_json)
lazy val mock_server = (project in file("modules/mock-server"))
.settings(
assembly / assemblyJarName := "mock-server.jar",
assembly / target := file("./output"),
ThisBuild / assemblyMergeStrategy := {
case PathList("META-INF", "io.netty.versions.properties") => MergeStrategy.first
case x =>
val oldStrategy = (ThisBuild / assemblyMergeStrategy).value
oldStrategy(x)
},
crossScalaVersions := Seq(versions.scala3),
publish / skip := true,
name := "mock-server",
libraryDependencies ++= Seq(
"dev.zio" %% "zio-http" % versions.zioHttp
)
)
.settings(commonSettings)
.dependsOn(core, zio_json)
lazy val root = (project in file("."))
.settings(
publish / skip := true,
name := globals.projectName
)
.aggregate(core, requests, upickle, sttp_core, zio_json, integration_test)