-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.sbt
255 lines (235 loc) · 8.75 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
import sbtghactions.UseRef
inThisBuild(
List(
organization := "org.polyvariant",
homepage := Some(url("https://github.com/polyvariant/sttp-oauth2")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
"majk-p",
"Michał Pawlik",
url("https://michalp.net")
)
),
versionScheme := Some("early-semver")
)
)
def crossPlugin(x: sbt.librarymanagement.ModuleID) = compilerPlugin(x.cross(CrossVersion.full))
val Scala212 = "2.12.19"
val Scala213 = "2.13.13"
val Scala3 = "3.3.3"
val GraalVM11 = "[email protected]"
ThisBuild / scalaVersion := Scala213
ThisBuild / crossScalaVersions := Seq(Scala212, Scala213, Scala3)
ThisBuild / githubWorkflowJavaVersions := Seq(GraalVM11)
ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(List("test", "docs/mdoc", "mimaReportBinaryIssues"))
) // NOTE those run separately for every ScalaVersion in `crossScalaVersions`
//sbt-ci-release settings
ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
ThisBuild / githubWorkflowPublishTargetBranches := Seq(
// the default is master - https://github.com/djspiewak/sbt-github-actions/issues/41
RefPredicate.Equals(Ref.Branch("main")),
RefPredicate.StartsWith(Ref.Tag("v"))
)
ThisBuild / githubWorkflowPublishPreamble := Seq(WorkflowStep.Use(UseRef.Public("olafurpg", "setup-gpg", "v3")))
ThisBuild / githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("ci-release")))
ThisBuild / githubWorkflowEnv ++= List("PGP_PASSPHRASE", "PGP_SECRET", "SONATYPE_PASSWORD", "SONATYPE_USERNAME").map { envKey =>
envKey -> s"$${{ secrets.$envKey }}"
}.toMap
ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"
ThisBuild / sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
val Versions = new {
val catsCore = "2.8.0"
val catsEffect = "3.3.14"
val catsEffect2 = "2.5.5"
val circe = "0.14.6"
val jsoniter = "2.30.7"
val monix = "3.4.1"
val scalaTest = "3.2.19"
val sttp = "3.9.8"
val refined = "0.10.3"
val scalaCache = "1.0.0-M6"
}
def compilerPlugins =
libraryDependencies ++= (if (scalaVersion.value.startsWith("3")) Seq()
else
Seq(
compilerPlugin("org.typelevel" % "kind-projector" % "0.13.3" cross CrossVersion.full),
compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1")
))
val mimaSettings =
// revert the commit that made this change after releasing a new version
// mimaPreviousArtifacts := {
// val currentVersion = version.value
// lazy val onlyPatchChanged =
// previousStableVersion.value.flatMap(CrossVersion.partialVersion) == CrossVersion.partialVersion(currentVersion)
// lazy val isRcOrMilestone = currentVersion.contains("-M") || currentVersion.contains("-RC")
// if (onlyPatchChanged && !isRcOrMilestone) {
// previousStableVersion.value.map(organization.value %% moduleName.value % _).toSet
// } else {
// Set.empty
// }
// }
mimaPreviousArtifacts := Set.empty
lazy val oauth2 = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.settings(
name := "sttp-oauth2",
libraryDependencies ++= Seq(
"com.softwaremill.sttp.client3" %%% "core" % Versions.sttp,
"org.typelevel" %%% "cats-core" % Versions.catsCore,
"eu.timepit" %%% "refined" % Versions.refined,
"org.scalatest" %%% "scalatest" % Versions.scalaTest % Test
),
mimaSettings,
compilerPlugins
)
.jsSettings(
libraryDependencies ++= Seq("org.scala-js" %%% "scala-js-macrotask-executor" % "1.1.1")
)
lazy val `oauth2-circe` = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.in(file("oauth2-circe"))
.settings(
name := "sttp-oauth2-circe",
libraryDependencies ++= Seq(
"io.circe" %%% "circe-parser" % Versions.circe,
"io.circe" %%% "circe-core" % Versions.circe,
"io.circe" %%% "circe-refined" % Versions.circe
),
mimaSettings,
compilerPlugins
)
.dependsOn(oauth2 % "compile->compile;test->test")
lazy val `oauth2-jsoniter` = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.in(file("oauth2-jsoniter"))
.settings(
name := "sttp-oauth2-jsoniter",
libraryDependencies ++= Seq(
"com.github.plokhotnyuk.jsoniter-scala" %%% "jsoniter-scala-core" % Versions.jsoniter,
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % Versions.jsoniter % "compile-internal"
),
mimaSettings,
compilerPlugins,
scalacOptions ++= Seq("-Wconf:cat=deprecation:info") // jsoniter-scala macro-generated code uses deprecated methods
)
.dependsOn(oauth2 % "compile->compile;test->test")
lazy val docs = project
.in(file("mdoc")) // important: it must not be docs/
.settings(
mdocVariables := Map(
"VERSION" -> {
if (isSnapshot.value) previousStableVersion.value.get else version.value
}
)
)
.dependsOn(oauth2.jvm)
.enablePlugins(MdocPlugin, DocusaurusPlugin)
lazy val `oauth2-cache` = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.settings(
name := "sttp-oauth2-cache",
mimaSettings,
compilerPlugins
)
.dependsOn(oauth2)
// oauth2-cache-scalacache doesn't have JS support because scalacache doesn't compile for js https://github.com/cb372/scalacache/issues/354#issuecomment-913024231
lazy val `oauth2-cache-scalacache` = project
.settings(
name := "sttp-oauth2-cache-scalacache",
libraryDependencies ++= Seq(
"com.github.cb372" %%% "scalacache-core" % Versions.scalaCache,
"com.github.cb372" %% "scalacache-caffeine" % Versions.scalaCache % Test,
"org.typelevel" %%% "cats-effect-kernel" % Versions.catsEffect,
"org.typelevel" %%% "cats-effect-std" % Versions.catsEffect,
"org.typelevel" %%% "cats-effect" % Versions.catsEffect % Test,
"org.typelevel" %%% "cats-effect-testkit" % Versions.catsEffect % Test,
"org.scalatest" %%% "scalatest" % Versions.scalaTest % Test
),
mimaPreviousArtifacts := Set.empty,
compilerPlugins
)
.dependsOn(`oauth2-cache`.jvm)
// oauth2-cache-cats doesn't have JS support because cats effect does not provide realTimeInstant on JS
lazy val `oauth2-cache-cats` = project
.settings(
name := "sttp-oauth2-cache-cats",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-effect-kernel" % Versions.catsEffect,
"org.typelevel" %%% "cats-effect-std" % Versions.catsEffect,
"org.typelevel" %%% "cats-effect" % Versions.catsEffect % Test,
"org.typelevel" %%% "cats-effect-testkit" % Versions.catsEffect % Test,
"org.scalatest" %%% "scalatest" % Versions.scalaTest % Test
),
mimaSettings,
compilerPlugins
)
.dependsOn(`oauth2-cache`.jvm)
// oauth2-cache-ce2 doesn't have JS support because cats effect does not provide realTimeInstant on JS
lazy val `oauth2-cache-ce2` = project
.settings(
name := "sttp-oauth2-cache-ce2",
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % Versions.catsEffect2,
"org.typelevel" %% "cats-effect-laws" % Versions.catsEffect2 % Test,
"org.scalatest" %% "scalatest" % Versions.scalaTest % Test
),
mimaSettings,
compilerPlugins
)
.dependsOn(`oauth2-cache`.jvm)
lazy val `oauth2-cache-zio` = project
.settings(
name := "sttp-oauth2-cache-zio",
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % "2.1.7",
"dev.zio" %% "zio-test" % "2.1.7" % Test,
"dev.zio" %% "zio-test-sbt" % "2.1.7" % Test
),
mimaSettings,
compilerPlugins,
scalacOptions -= "-Ykind-projector",
scalacOptions ++= (
if (scalaVersion.value.startsWith("3")) Seq("-Ykind-projector:underscores")
else Seq("-P:kind-projector:underscore-placeholders")
)
)
.dependsOn(`oauth2-cache`.jvm)
lazy val `oauth2-cache-future` = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.settings(
name := "sttp-oauth2-cache-future",
libraryDependencies ++= Seq(
"io.monix" %%% "monix-execution" % Versions.monix,
"org.scalatest" %%% "scalatest" % Versions.scalaTest % Test
),
mimaSettings,
compilerPlugins
)
.dependsOn(`oauth2-cache`)
val root = project
.in(file("."))
.settings(
publish / skip := true,
mimaPreviousArtifacts := Set.empty
)
// after adding a module remember to regenerate ci.yml using `sbt githubWorkflowGenerate`
.aggregate(
oauth2.jvm,
oauth2.js,
`oauth2-cache`.jvm,
`oauth2-cache`.js,
`oauth2-cache-cats`,
`oauth2-cache-ce2`,
`oauth2-cache-zio`,
`oauth2-cache-future`.jvm,
`oauth2-cache-future`.js,
`oauth2-cache-scalacache`,
`oauth2-circe`.jvm,
`oauth2-circe`.js,
`oauth2-jsoniter`.jvm,
`oauth2-jsoniter`.js
)