-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sbt
279 lines (254 loc) · 8.61 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
inThisBuild(
List(
organization := "com.kubukoz",
homepage := Some(url("https://github.com/kubukoz/smithy-playground")),
licenses := List("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
"kubukoz",
"Jakub Kozłowski",
url("https://kubukoz.com"),
)
),
)
)
val ScalaLTS = "3.3.4"
val ScalaNext = "3.5.2"
val jsoniterVersion = "2.32.0"
ThisBuild / scalaVersion := ScalaNext
ThisBuild / versionScheme := Some("early-semver")
import scala.sys.process.*
import scala.util.chaining.*
// Workaround for https://github.com/coursier/coursier/issues/2001
// from https://github.com/coursier/coursier/issues/2001#issuecomment-2556556628
def jsoniterFix(deps: Seq[ModuleID]) =
deps.map(
_.exclude("com.github.plokhotnyuk.jsoniter-scala", "jsoniter-scala-core_3")
) ++ Seq(
"com.github.plokhotnyuk.jsoniter-scala" % "jsoniter-scala-core_2.13" % jsoniterVersion
)
def crossPlugin(
x: sbt.librarymanagement.ModuleID
) = compilerPlugin(x.cross(CrossVersion.full))
val compilerPlugins =
libraryDependencies ++= List(
crossPlugin("org.polyvariant" % "better-tostring" % "0.3.17")
) ++ (if (scalaVersion.value.startsWith("3"))
Nil
else
List(
crossPlugin("org.typelevel" % "kind-projector" % "0.13.3")
))
// For coursier's "latest.integration"
ThisBuild / dynverSeparator := "-"
val commonSettings = Seq(
organization := "com.kubukoz.playground",
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % "2.12.0",
"org.typelevel" %% "cats-mtl" % "1.5.0",
"com.disneystreaming" %% "weaver-cats" % "0.8.4" % Test,
"com.disneystreaming" %% "weaver-discipline" % "0.8.4" % Test,
"com.disneystreaming" %% "weaver-scalacheck" % "0.8.4" % Test,
"com.softwaremill.diffx" %% "diffx-core" % "0.9.0" % Test,
"com.softwaremill.diffx" %% "diffx-cats" % "0.9.0" % Test,
),
compilerPlugins,
scalacOptions -= "-Xfatal-warnings",
scalacOptions -= "-Vtype-diffs",
scalacOptions -= "-language:existentials",
// https://github.com/lampepfl/dotty/issues/18674
Test / scalacOptions -= "-Wunused:implicits",
Test / scalacOptions -= "-Wunused:explicits",
Test / scalacOptions -= "-Wunused:imports",
Test / scalacOptions -= "-Wunused:locals",
Test / scalacOptions -= "-Wunused:params",
Test / scalacOptions -= "-Wunused:privates",
//
scalacOptions += "-no-indent",
scalacOptions ++= {
if (scalaVersion.value.startsWith("3.5"))
Seq(
// for cats-tagless macros
"-experimental"
)
else
Nil
},
Test / scalacOptions += "-Wconf:cat=deprecation:silent,msg=Specify both message and version:silent",
scalacOptions += "-release:11",
mimaFailOnNoPrevious := false,
)
def module(
name: String
) = Project(name, file("modules") / name)
.settings(
commonSettings
)
// Plugin interface. Keeps binary compatibility guarantees (mostly tied to smithy4s's bincompat).
lazy val pluginCore = module("plugin-core").settings(
libraryDependencies ++= Seq(
"com.disneystreaming.smithy4s" %% "smithy4s-http4s" % smithy4sVersion.value
).pipe(jsoniterFix),
// mimaPreviousArtifacts := Set(organization.value %% name.value % "0.7.0"),
mimaPreviousArtifacts := Set.empty,
scalaVersion := ScalaLTS,
)
lazy val pluginSample = module("plugin-sample")
.dependsOn(pluginCore)
.settings(
// used for tests only
mimaPreviousArtifacts := Set.empty
)
// AST of SmithyQL language (plus DSL and minor utilities for building these)
lazy val ast = module("ast")
// Source code model (comments, locations, etc.)
lazy val source = module("source")
.dependsOn(ast)
// Parser interface / implementation
lazy val parser = module("parser")
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-parse" % "1.1.0",
"io.circe" %% "circe-generic" % "0.14.10" % Test,
"io.circe" %% "circe-parser" % "0.14.10" % Test,
"co.fs2" %% "fs2-io" % "3.11.0" % Test,
)
)
.dependsOn(
ast % "test->test;compile->compile",
source % "test->test;compile->compile",
)
// Formatter for the SmithyQL language constructs
lazy val formatter = module("formatter")
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "paiges-cats" % "0.4.4"
)
)
.dependsOn(
ast,
source,
parser % "test->test",
)
lazy val examples = module("examples")
.settings(
libraryDependencies ++= Seq(
"com.disneystreaming.smithy4s" %% "smithy4s-core" % smithy4sVersion.value,
"com.disneystreaming.smithy4s" %% "smithy4s-aws-kernel" % smithy4sVersion.value,
),
publish := false,
// generated code
scalacOptions += "-Wconf:cat=deprecation:silent",
)
.enablePlugins(Smithy4sCodegenPlugin)
// not named "protocol" to leave space for a potential java-only protocol jar
lazy val protocol4s = module("protocol4s")
.settings(
libraryDependencies ++= Seq(
"com.disneystreaming.smithy4s" %% "smithy4s-core" % smithy4sVersion.value
)
)
.enablePlugins(Smithy4sCodegenPlugin)
// Most of the core functionality of SmithyQL (compilation, analysis, evaluation)
// also: SmithyQL standard library
lazy val core = module("core")
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % "3.5.7",
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % jsoniterVersion,
"com.disneystreaming.smithy4s" %% "smithy4s-dynamic" % smithy4sVersion.value,
"com.disneystreaming.smithy4s" %% "smithy4s-http4s" % smithy4sVersion.value,
"com.disneystreaming.smithy4s" %% "smithy4s-aws-http4s" % smithy4sVersion.value,
"com.disneystreaming.smithy4s" % "smithy4s-protocol" % smithy4sVersion.value % Test,
"com.disneystreaming.alloy" % "alloy-core" % "0.3.14" % Test,
"software.amazon.smithy" % "smithy-aws-traits" % "1.53.0" % Test,
).pipe(jsoniterFix)
)
.dependsOn(
protocol4s,
examples % "test->compile",
pluginCore,
ast,
source % "test->test;compile->compile",
parser % "test->compile;test->test",
formatter,
)
// LSP-like interfaces like CodeLensProvider, which are later adapted into actual lsp
lazy val languageSupport = module("language-support")
.dependsOn(core % "test->test;compile->compile", parser)
// Adapters for language services to LSP, actual LSP server binding, entrypoint
lazy val lsp = module("lsp")
.settings(
libraryDependencies ++= Seq(
"org.eclipse.lsp4j" % "org.eclipse.lsp4j" % "0.23.1",
"io.circe" %% "circe-core" % "0.14.10",
"org.http4s" %% "http4s-ember-client" % "0.23.30",
"org.http4s" %% "http4s-ember-server" % "0.23.30" % Test,
("io.get-coursier" % "coursier_2.13" % "2.1.23")
.exclude("org.scala-lang.modules", "scala-collection-compat_2.13"),
"org.typelevel" %% "cats-tagless-core" % "0.16.2",
).pipe(jsoniterFix),
buildInfoPackage := "playground.lsp.buildinfo",
buildInfoKeys ++= Seq(version, scalaBinaryVersion),
(Test / test) := {
(pluginCore / publishLocal).value
(pluginSample / publishLocal).value
(Test / test).value
},
)
.enablePlugins(BuildInfoPlugin)
.dependsOn(languageSupport)
lazy val e2e = module("e2e")
.enablePlugins(BuildInfoPlugin)
.settings(
buildInfoKeys ++=
Seq[BuildInfoKey.Entry[_]]( // do you know how to simplify this? let me know please!
Def
.task {
s"""${(lsp / organization).value}::${(lsp / moduleName).value}:${(lsp / version).value}"""
}
// todo: replace with a full publishLocal before e2e in particular gets run (but not before tests run normally)
.dependsOn(
lsp / publishLocal,
languageSupport / publishLocal,
core / publishLocal,
parser / publishLocal,
pluginCore / publishLocal,
source / publishLocal,
ast / publishLocal,
formatter / publishLocal,
protocol4s / publishLocal,
)
.taskValue
.named("lspArtifact")
),
publish / skip := true,
Test / fork := true,
)
.dependsOn(lsp)
val writeVersion = taskKey[Unit]("Writes the current version to the `.version` file")
lazy val root = project
.in(file("."))
.settings(
publish / skip := true,
mimaFailOnNoPrevious := false,
addCommandAlias("ci", "+test;+mimaReportBinaryIssues;+publishLocal;writeVersion"),
writeVersion := {
IO.write(file(".version"), version.value)
},
)
.aggregate(
ast,
source,
core,
examples,
parser,
formatter,
languageSupport,
lsp,
protocol4s,
pluginCore,
pluginSample,
e2e,
)