forked from bblfish/httpSig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
236 lines (214 loc) · 9.25 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
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.firefox.FirefoxOptions
import org.scalajs.jsenv.selenium.SeleniumJSEnv
import org.openqa.selenium.safari.SafariOptions
import Dependencies.*
// this import is needed to be able to run `set useJSEnv := JSEnv.Firefox` in sbt
import JSEnv.*
name := "httpSig"
ThisBuild / tlBaseVersion := "0.4"
ThisBuild / tlUntaggedAreSnapshots := true
ThisBuild / developers := List(
tlGitHubDev("bblfish", "Henry Story")
)
ThisBuild / startYear := Some(2021)
ThisBuild / organization := "net.bblfish.crypto"
ThisBuild / organizationName := "Henry Story"
ThisBuild / homepage := Some(url("https://github.com/bblfish/httpSig"))
ThisBuild / scmInfo := Some(
ScmInfo(url("https://github.com/bblfish/httpSig"), "[email protected]:bblfish/httpSig.git")
)
ThisBuild / tlCiReleaseBranches := Seq()
ThisBuild / tlCiReleaseTags := false // don't publish artifacts on github
//ThisBuild / tlSonatypeUseLegacyHost := false // TODO remove
ThisBuild / crossScalaVersions := Seq("3.2.1")
// check https://dotty.epfl.ch/docs/reference/experimental/canthrow.html
//ThisBuild / scalaVersion := "3.3.0-RC1-bin-20221130-72c4ffd-NIGHTLY"
ThisBuild / githubWorkflowBuildPreamble ++= Seq(
WorkflowStep.Use(
UseRef.Public("actions", "setup-node", "v2.4.0"),
name = Some("Setup NodeJS v14 LTS"),
params = Map("node-version" -> "14"),
cond = Some("matrix.project == 'rootJS' && matrix.jsenv == 'NodeJS'")
)
)
lazy val jsenvs = List(JSEnv.NodeJS, JSEnv.Chrome, JSEnv.Firefox).map(_.toString)
ThisBuild / githubWorkflowBuildMatrixAdditions += "jsenv" -> jsenvs
ThisBuild / githubWorkflowBuildSbtStepPreamble += s"set Global / useJSEnv := JSEnv.$${{ matrix.jsenv }}"
ThisBuild / githubWorkflowBuildMatrixExclusions += MatrixExclude(
Map("project" -> "rootJS", "jsenv" -> JSEnv.NodeJS.toString)
)
ThisBuild / githubWorkflowBuildMatrixExclusions ++= {
for {
jsenv <- jsenvs.tail
} yield MatrixExclude(Map("project" -> "rootJVM", "jsenv" -> jsenv))
}
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17"))
ThisBuild / resolvers += sonatypeSNAPSHOT
lazy val useJSEnv =
settingKey[JSEnv]("Browser for running Scala.js tests")
Global / useJSEnv := JSEnv.NodeJS //what should go in its place?
ThisBuild / Test / jsEnv := {
val old = (Test / jsEnv).value
useJSEnv.value match {
case JSEnv.NodeJS => old
case JSEnv.Firefox =>
val options = new FirefoxOptions()
options.setHeadless(true)
new SeleniumJSEnv(options)
case JSEnv.Chrome =>
val options = new ChromeOptions()
options.setHeadless(true)
new SeleniumJSEnv(options)
/* Safari is very limited, allowing only one session at a time, and no headless mode.
* but we leave this here, to keep track of evolution
* https://developer.apple.com/documentation/webkit/about_webdriver_for_safari */
case JSEnv.Safari =>
val o = new SafariOptions()
new SeleniumJSEnv(o)
}
}
lazy val root = tlCrossRootProject.aggregate(rfc8941, ietfSigHttp, http4sSig, akkaSig)
lazy val commonSettings = Seq(
name := "HttpSig Library",
description := "Set of libraries implementing IETF `Signing Http Messages` RFC",
startYear := Some(2021),
updateOptions := updateOptions.value.withCachedResolution(
true
) // to speed up dependency resolution
)
lazy val rfc8941 = crossProject(JVMPlatform, JSPlatform)
.in(file("rfc8941"))
.settings(commonSettings*)
.settings(
name := "rfc8941",
description := "RFC8941 Structured Field Values parser",
libraryDependencies += cats.parse.value,
libraryDependencies += scodec.bits.value,
libraryDependencies += tests.munit.value % Test
).jsSettings(
scalacOptions ++= scala3jsOptions // ++= is really important. Do NOT use `:=` - that will block testing
).jvmSettings(
scalacOptions := scala3Options
)
lazy val ietfSigHttp = crossProject(JVMPlatform, JSPlatform)
.in(file("ietfSig"))
.settings(commonSettings*)
.settings(
name := "Signing Http Messages Core",
description := "Generic implementation of the IETF `Signing Http Messages` RFC",
libraryDependencies += cats.bobcats.value
)
.jsSettings(
scalacOptions ++= scala3jsOptions // ++= is really important. Do NOT use `:=` - that will block testing
)
.jvmSettings(
scalacOptions := scala3Options,
libraryDependencies ++= java.bouncy
)
.dependsOn(rfc8941)
lazy val testUtils = crossProject(JVMPlatform, JSPlatform)
.in(file("test"))
.settings(commonSettings*)
.settings(
name := "test utils",
description := "Test Utilities"
)
lazy val ietfSigHttpTests = crossProject(JVMPlatform, JSPlatform)
.in(file("ietfSigTests"))
.settings(commonSettings*)
.settings(
name := "IETF Http Signature Tests",
description := "Generic tests for generic implementation of IETF `Signing Http Messages`",
libraryDependencies ++= Seq(
tests.munitEffect.value,
cats.caseInsensitive.value,
tests.munit.value % Test,
tests.catsEffectTestKit.value,
cats.bobcats.value classifier ("tests"), // bobcats test examples,
cats.bobcats.value classifier ("tests-sources") // bobcats test examples
)
)
.jsSettings(
scalacOptions ++= scala3jsOptions // ++= is really important. Do NOT use `:=` - that will block testing
)
.jvmSettings(
scalacOptions := scala3Options,
libraryDependencies ++= java.bouncy
)
.dependsOn(ietfSigHttp)
// we only use Java akka here (doing akka-js would be a whole project by itself)
lazy val akkaSig = project
.in(file("akka"))
.settings(commonSettings*)
.settings(
name := "Akka Http Signature",
description := "Signing HTTP Messages parser for Akka HTTP Messages",
scalacOptions := scala3Options,
libraryDependencies ++= Seq(
akka.http.value,
akka.stream.value,
akka.typed.value,
cats.catsEffect.value
// java.nimbusDS
),
libraryDependencies ++= java.bouncy
).dependsOn(ietfSigHttp.jvm, ietfSigHttpTests.jvm % Test)
lazy val http4sSig = crossProject(JVMPlatform, JSPlatform)
.in(file("http4s"))
.settings(commonSettings*)
.settings(
name := "http4s Http Signature",
description := "Signing HTTP Messages parser for http4s headers library",
libraryDependencies ++= Seq(
http4s.client.value,
http4s.theDsl.value
)
)
.jsSettings(
scalacOptions ++= scala3jsOptions, // ++= is really important. Do NOT use `:=` - that will block testing
libraryDependencies ++= Seq(
cats.bobcats.value % Test,
tests.scalaCheck.value % Test,
tests.discipline.value % Test,
tests.laws.value % Test
)
)
.jvmSettings(
scalacOptions := scala3Options,
libraryDependencies ++= java.bouncy
)
.dependsOn(ietfSigHttp, ietfSigHttpTests % Test, testUtils % Test)
lazy val scala3Options = Seq(
// "-language:experimental.saferExceptions",
// "-classpath", "foo:bar:...", // Add to the classpath.
// "-encoding", "utf-8", // Specify character encoding used by source files.
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
// "-explain", // Explain errors in more detail.
// "-explain-types", // Explain type errors in more detail.
"-indent", // Together with -rewrite, remove {...} syntax when possible due to significant indentation.
// "-no-indent", // Require classical {...} syntax, indentation is not significant.
"-new-syntax", // Require `then` and `do` in control expressions.
// "-old-syntax", // Require `(...)` around conditions.
// "-language:Scala2", // Compile Scala 2 code, highlight what needs updating
// "-language:strictEquality", // Require +derives Eql+ for using == or != comparisons
// "-rewrite", // Attempt to fix code automatically. Use with -indent and ...-migration.
// "-scalajs", // Compile in Scala.js mode (requires scalajs-library.jar on the classpath).
"-source:future", // Choices: future and future-migration. I use this to force future deprecation warnings, etc.
// "-Xfatal-warnings", // Fail on warnings, not just errors
// "-Xmigration", // Warn about constructs whose behavior may have changed since version.
// "-Ysafe-init", // Warn on field access before initialization
"-Yexplicit-nulls" // For explicit nulls behavior.
)
lazy val scala3jsOptions = Seq(
// "-language:experimental.saferExceptions",
// "-classpath", "foo:bar:...", // Add to the classpath.
"-indent", // Together with -rewrite, remove {...} syntax when possible due to significant indentation.
"-new-syntax", // Require `then` and `do` in control expressions.
"-source:future", // Choices: future and future-migration. I use this to force future deprecation warnings, etc.
"-Yexplicit-nulls" // For explicit nulls behavior.
// if the following are set we get an error using ++= stating they are already set
// "-deprecation", "-unchecked", "-feature",
)