forked from zio/zio-http
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
340 lines (319 loc) · 11.5 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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
import BuildHelper.*
import Dependencies.{scalafmt, *}
import scala.concurrent.duration.*
val releaseDrafterVersion = "5"
// Setting default log level to INFO
val _ = sys.props += ("ZIOHttpLogLevel" -> Debug.ZIOHttpLogLevel)
// CI Configuration
ThisBuild / githubWorkflowJavaVersions := Seq(
JavaSpec.graalvm(Graalvm.Distribution("graalvm"), "17"),
JavaSpec.temurin("8"),
)
ThisBuild / githubWorkflowPREventTypes := Seq(
PREventType.Opened,
PREventType.Synchronize,
PREventType.Reopened,
PREventType.Edited,
PREventType.Labeled,
)
ThisBuild / githubWorkflowAddedJobs :=
Seq(
WorkflowJob(
id = "update_release_draft",
name = "Release Drafter",
steps = List(WorkflowStep.Use(UseRef.Public("release-drafter", "release-drafter", s"v${releaseDrafterVersion}"))),
cond = Option("${{ github.base_ref == 'main' }}"),
),
) ++ ScoverageWorkFlow(50, 60) ++ JmhBenchmarkWorkflow(1) ++ BenchmarkWorkFlow()
ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
ThisBuild / githubWorkflowPublishTargetBranches += RefPredicate.StartsWith(Ref.Tag("v"))
ThisBuild / githubWorkflowPublish :=
Seq(
WorkflowStep.Sbt(
List("ci-release"),
name = Some("Release"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}",
"CI_SONATYPE_RELEASE" -> "${{ secrets.CI_SONATYPE_RELEASE }}",
),
),
WorkflowStep.Sbt(
List("ci-release"),
name = Some("Release Shaded"),
env = Map(
Shading.env.PUBLISH_SHADED -> "true",
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}",
"CI_SONATYPE_RELEASE" -> "${{ secrets.CI_SONATYPE_RELEASE }}",
),
),
)
//scala fix isn't available for scala 3 so ensure we only run the fmt check
//using the latest scala 2.13
ThisBuild / githubWorkflowBuildPreamble := Seq(
WorkflowStep.Run(
name = Some("Check formatting"),
commands = List(s"sbt ++${Scala213} fmtCheck"),
cond = Some(s"matrix.scala == '${Scala213}'"),
),
)
ThisBuild / githubWorkflowBuildPostamble :=
WorkflowJob(
"checkDocGeneration",
"Check doc generation",
List(
WorkflowStep.Run(
commands = List(s"sbt ++${Scala213} doc"),
name = Some("Check doc generation"),
cond = Some("${{ github.event_name == 'pull_request' }}"),
),
),
scalas = List(Scala213),
).steps ++
WorkflowJob(
id = "zio-http-shaded-tests",
name = "Test shaded version of zio-http",
steps = List(
WorkflowStep.Sbt(
name = Some("zio-http-shaded Tests"),
commands = List("zioHttpShadedTests/test"),
cond = Some(s"matrix.scala == '$Scala213'"),
env = Map(Shading.env.PUBLISH_SHADED -> "true"),
),
),
).steps
inThisBuild(
List(
organization := "dev.zio",
homepage := Some(url("https://zio.dev/zio-http/")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
),
)
ThisBuild / githubWorkflowBuildTimeout := Some(60.minutes)
lazy val aggregatedProjects: Seq[ProjectReference] =
if (Shading.shadingEnabled) {
Seq(
zioHttpJVM,
zioHttpJS,
zioHttpTestkit,
)
} else {
Seq(
zioHttpJVM,
zioHttpJS,
zioHttpBenchmarks,
zioHttpCli,
zioHttpGen,
zioHttpHtmx,
zioHttpExample,
zioHttpTestkit,
docs,
)
}
lazy val root = (project in file("."))
.settings(stdSettings("zio-http-root"))
.settings(publishSetting(false))
.aggregate(aggregatedProjects: _*)
lazy val zioHttp = crossProject(JSPlatform, JVMPlatform)
.in(file("zio-http"))
.enablePlugins(Shading.plugins(): _*)
.settings(stdSettings("zio-http"))
.settings(publishSetting(true))
.settings(settingsWithHeaderLicense)
.settings(meta)
.settings(crossProjectSettings)
.settings(Shading.shadingSettings())
.settings(
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) =>
Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)
case _ => Seq.empty
}
},
)
.jvmSettings(
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"),
libraryDependencies ++= Seq(
`zio`,
`zio-streams`,
`zio-schema`,
`zio-schema-json`,
`zio-schema-protobuf`,
`zio-test`,
`zio-test-sbt`,
),
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n <= 12 =>
Seq(`scala-compact-collection`)
case _ => Seq.empty
}
},
libraryDependencies ++= netty ++ Seq(`netty-incubator`),
)
.jsSettings(
ThisProject / fork := false,
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")),
libraryDependencies ++= Seq(
"io.github.cquiroz" %%% "scala-java-time" % "2.5.0",
"io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.5.0",
"org.scala-js" %%% "scalajs-dom" % "2.8.0",
"dev.zio" %%% "zio-test" % ZioVersion % "test",
"dev.zio" %%% "zio-test-sbt" % ZioVersion % "test",
"dev.zio" %%% "zio" % ZioVersion,
"dev.zio" %%% "zio-streams" % ZioVersion,
"dev.zio" %%% "zio-schema" % ZioSchemaVersion,
"dev.zio" %%% "zio-schema-json" % ZioSchemaVersion,
"dev.zio" %%% "zio-schema-protobuf" % ZioSchemaVersion,
),
)
lazy val zioHttpJS = zioHttp.js
.settings(scalaJSUseMainModuleInitializer := true)
lazy val zioHttpJVM = zioHttp.jvm
/**
* Special subproject to sanity test the shaded version of zio-http. Run using
* `sbt -Dpublish.shaded zioHttpShadedTests/test`. This will trigger
* `publishLocal` on zio-http and then run tests using the shaded artifact as a
* dependency, instead of zio-http classes.
*/
lazy val zioHttpShadedTests = if (Shading.shadingEnabled) {
(project in file("zio-http-shaded-tests"))
.settings(stdSettings("zio-http-shaded-tests"))
.settings(
Compile / sources := Nil,
Test / sources := (
baseDirectory.value / ".." / "zio-http" / "src" / "test" / "scala" ** "*.scala" ---
// Exclude tests of netty specific internal stuff
baseDirectory.value / ".." / "zio-http" / "src" / "test" / "scala" ** "netty" ** "*.scala"
).get,
Test / scalaSource := (baseDirectory.value / ".." / "zio-http" / "src" / "test" / "scala"),
Test / resourceDirectory := (baseDirectory.value / ".." / "zio-http" / "src" / "test" / "resources"),
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"),
libraryDependencies ++= Seq(
`zio-test-sbt`,
`zio-test`,
"dev.zio" %% "zio-http-shaded" % version.value,
),
)
.settings(publishSetting(false))
.settings(Test / test := (Test / test).dependsOn(zioHttpJVM / publishLocal).value)
} else {
(project in file(".")).settings(
Compile / sources := Nil,
Test / sources := Nil,
name := "noop",
publish / skip := true,
)
}
lazy val zioHttpBenchmarks = (project in file("zio-http-benchmarks"))
.enablePlugins(JmhPlugin)
.settings(stdSettings("zio-http-benchmarks"))
.settings(publishSetting(false))
.settings(
libraryDependencies ++= Seq(
// "com.softwaremill.sttp.tapir" %% "tapir-akka-http-server" % "1.1.0",
"com.softwaremill.sttp.tapir" %% "tapir-http4s-server" % "1.5.1",
"com.softwaremill.sttp.tapir" %% "tapir-json-circe" % "1.5.1",
"com.softwaremill.sttp.client3" %% "core" % "3.9.5",
// "dev.zio" %% "zio-interop-cats" % "3.3.0",
"org.slf4j" % "slf4j-api" % "2.0.13",
"org.slf4j" % "slf4j-simple" % "2.0.13",
),
)
.dependsOn(zioHttpJVM)
lazy val zioHttpCli = (project in file("zio-http-cli"))
.settings(stdSettings("zio-http-cli"))
.settings(
libraryDependencies ++= Seq(`zio-cli`),
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"),
libraryDependencies ++= Seq(
`zio-test`,
`zio-test-sbt`,
),
)
.dependsOn(zioHttpJVM)
.dependsOn(zioHttpTestkit % Test)
lazy val zioHttpHtmx = (project in file("zio-http-htmx"))
.settings(
stdSettings("zio-http-htmx"),
publishSetting(true),
)
.dependsOn(zioHttpJVM)
lazy val zioHttpExample = (project in file("zio-http-example"))
.settings(stdSettings("zio-http-example"))
.settings(publishSetting(false))
.settings(runSettings(Debug.Main))
.settings(libraryDependencies ++= Seq(`jwt-core`, `zio-schema-json`))
.settings(
libraryDependencies ++= Seq(
"dev.zio" %% "zio-config" % ZioConfigVersion,
"dev.zio" %% "zio-config-typesafe" % ZioConfigVersion,
"dev.zio" %% "zio-config-magnolia" % ZioConfigVersion,
"dev.zio" %% "zio-metrics-connectors" % "2.3.1",
"dev.zio" %% "zio-metrics-connectors-prometheus" % "2.3.1",
),
)
.dependsOn(zioHttpJVM, zioHttpCli, zioHttpGen)
lazy val zioHttpGen = (project in file("zio-http-gen"))
.settings(stdSettings("zio-http-gen"))
.settings(publishSetting(true))
.settings(
libraryDependencies ++= Seq(
`zio`,
`zio-test`,
`zio-test-sbt`,
scalafmt.cross(CrossVersion.for3Use2_13),
),
)
.dependsOn(zioHttpJVM)
lazy val zioHttpTestkit = (project in file("zio-http-testkit"))
.enablePlugins(Shading.plugins(): _*)
.settings(stdSettings("zio-http-testkit"))
.settings(publishSetting(true))
.settings(Shading.shadingSettings())
.settings(
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"),
libraryDependencies ++= netty ++ Seq(
`zio`,
`zio-test`,
`zio-test-sbt`,
),
)
.dependsOn(zioHttpJVM)
lazy val docs = project
.in(file("zio-http-docs"))
.settings(stdSettings("zio-http-docs"))
.settings(
fork := false,
moduleName := "zio-http-docs",
scalacOptions -= "-Yno-imports",
scalacOptions -= "-Xfatal-warnings",
projectName := "ZIO Http",
mainModuleName := (zioHttpJVM / moduleName).value,
projectStage := ProjectStage.Development,
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(zioHttpJVM),
ciWorkflowName := "Continuous Integration",
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"),
libraryDependencies ++= Seq(
`jwt-core`,
"dev.zio" %% "zio-test" % ZioVersion,
"dev.zio" %% "zio-config" % ZioConfigVersion,
"dev.zio" %% "zio-config-magnolia" % ZioConfigVersion,
"dev.zio" %% "zio-config-typesafe" % ZioConfigVersion
),
publish / skip := true,
mdocVariables ++= Map(
"ZIO_VERSION" -> ZioVersion,
"ZIO_SCHEMA_VERSION" -> ZioSchemaVersion,
"ZIO_CONFIG_VERSION" -> ZioConfigVersion,
)
)
.dependsOn(zioHttpJVM)
.enablePlugins(WebsitePlugin)
.dependsOn(zioHttpTestkit)