forked from polyvariant/sttp-oauth2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
213 lines (195 loc) · 7.27 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
import sbtghactions.UseRef
inThisBuild(
List(
organization := "com.ocadotechnology",
homepage := Some(url("https://github.com/ocadotechnology/sttp-oauth2")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
"majk-p",
"Michał Pawlik",
"michal.pawlik@ocado.com",
url("https://michalp.net")
),
Developer(
"tplaskowski",
"Tomek Pląskowski",
"t.plaskowski@ocado.com",
url("https://github.com/tplaskowski")
),
Developer(
"matwojcik",
"Mateusz Wójcik",
"mateusz.wojcik@ocado.com",
url("https://github.com/matwojcik")
)
),
versionScheme := Some("early-semver")
)
)
def crossPlugin(x: sbt.librarymanagement.ModuleID) = compilerPlugin(x.cross(CrossVersion.full))
val Scala212 = "2.12.16"
val Scala213 = "2.13.8"
val Scala3 = "3.1.3"
val GraalVM11 = "graalvm-ce-java11@20.3.0"
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
val Versions = new {
val catsCore = "2.8.0"
val catsEffect = "3.3.14"
val catsEffect2 = "2.5.5"
val circe = "0.14.2"
val monix = "3.4.1"
val scalaTest = "3.2.13"
val sttp = "3.3.18"
val refined = "0.10.1"
val scalaCache = "1.0.0-M6"
}
def compilerPlugins =
libraryDependencies ++= (if (scalaVersion.value.startsWith("3")) Seq()
else Seq(compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1")))
val mimaSettings =
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
}
}
// Workaround for https://github.com/typelevel/sbt-tpolecat/issues/102
val jsSettings = scalacOptions ++= (if (scalaVersion.value.startsWith("3")) Seq("-scalajs") else Seq())
lazy val oauth2 = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
.settings(
name := "sttp-oauth2",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % Versions.catsCore,
"io.circe" %%% "circe-parser" % Versions.circe,
"io.circe" %%% "circe-core" % Versions.circe,
"io.circe" %%% "circe-refined" % Versions.circe,
"com.softwaremill.sttp.client3" %%% "core" % Versions.sttp,
"com.softwaremill.sttp.client3" %%% "circe" % Versions.sttp,
"eu.timepit" %%% "refined" % Versions.refined,
"org.scalatest" %%% "scalatest" % Versions.scalaTest % Test
),
mimaSettings,
compilerPlugins
)
.jsSettings(
libraryDependencies ++= Seq("org.scala-js" %%% "scala-js-macrotask-executor" % "1.0.0"),
jsSettings
)
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
)
.jsSettings(jsSettings)
.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-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
)
.jsSettings(jsSettings)
.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-future`.jvm,
`oauth2-cache-future`.js,
`oauth2-cache-scalacache`
)