forked from scalameta/metals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
484 lines (464 loc) Β· 14.9 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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
def localSnapshotVersion = "0.7.7-SNAPSHOT"
def isCI = System.getenv("CI") != null
def crossSetting[A](
scalaVersion: String,
if211: List[A],
otherwise: List[A] = Nil
): List[A] =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, 11)) => if211
case _ => otherwise
}
inThisBuild(
List(
version ~= { dynVer =>
if (isCI) dynVer
else localSnapshotVersion // only for local publishng
},
scalaVersion := V.scala212,
crossScalaVersions := List(V.scala212),
scalacOptions ++= List(
"-target:jvm-1.8",
"-Yrangepos",
// -Xlint is unusable because of
// https://github.com/scala/bug/issues/10448
"-Ywarn-unused:imports"
),
addCompilerPlugin(
"org.scalameta" % "semanticdb-scalac" % V.scalameta cross CrossVersion.full
),
scalacOptions += s"-P:semanticdb:sourceroot:${baseDirectory.in(ThisBuild).value}",
organization := "org.scalameta",
licenses := Seq(
"Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")
),
homepage := Some(url("https://github.com/scalameta/metals")),
developers := List(
Developer(
"laughedelic",
"Alexey Alekhin",
"laughedelic@gmail.com",
url("https://github.com/laughedelic")
),
Developer(
"ckipp01",
"Chris Kipp",
"ckipp@pm.me",
url("https://wiki.chronica.xyz")
),
Developer(
"gabro",
"Gabriele Petronella",
"gabriele@buildo.io",
url("https://github.com/gabro")
),
Developer(
"mudsam",
"Johan Mudsam",
"johan@mudsam.com",
url("https://github.com/mudsam")
),
Developer(
"jvican",
"Jorge Vicente Cantero",
"jorgevc@fastmail.es",
url("https://jvican.github.io/")
),
Developer(
"marek1840",
"Marek Ε»arnowski",
"mzarnowski@virtuslab.com",
url("https://github.com/marek1840")
),
Developer(
"olafurpg",
"Γlafur PΓ‘ll Geirsson",
"olafurpg@gmail.com",
url("https://geirsson.com")
),
Developer(
"ShaneDelmore",
"Shane Delmore",
"sdelmore@twitter.com",
url("http://delmore.io")
),
Developer(
"tgodzik",
"Tomasz Godzik",
"tgodzik@virtuslab.com",
url("https://github.com/tgodzik")
)
),
testFrameworks := List(),
resolvers += Resolver.sonatypeRepo("public"),
dependencyOverrides += V.guava,
// faster publishLocal:
publishArtifact.in(packageDoc) := sys.env.contains("CI"),
publishArtifact.in(packageSrc) := sys.env.contains("CI"),
// forking options
javaOptions += {
import scala.collection.JavaConverters._
val props = System.getProperties
props
.stringPropertyNames()
.asScala
.map { configKey =>
s"-D$configKey=${props.getProperty(configKey)}"
}
.mkString(" ")
},
resolvers += Resolver.bintrayRepo("scalacenter", "releases")
)
)
onLoad.in(Global) ~= { old =>
if (!scala.util.Properties.isWin) {
import java.nio.file._
val prePush = Paths.get(".git", "hooks", "pre-push")
Files.createDirectories(prePush.getParent)
Files.write(
prePush,
"""#!/bin/sh
|set -eux
|bin/scalafmt --diff
|git diff --exit-code
|""".stripMargin.getBytes()
)
prePush.toFile.setExecutable(true)
}
old
}
cancelable.in(Global) := true
crossScalaVersions := Nil
addCommandAlias("scalafixAll", "all compile:scalafix test:scalafix")
addCommandAlias("scalafixCheck", "; scalafix --check ; test:scalafix --check")
commands += Command.command("save-expect") { s =>
"unit/test:runMain tests.SaveExpect" ::
s
}
lazy val V = new {
val scala210 = "2.10.7"
val scala211 = "2.11.12"
val scala212 = "2.12.10"
val scala213 = "2.13.1"
val scalameta = "4.3.0"
val semanticdb = scalameta
val bsp = "2.0.0-M4+10-61e61e87"
val bloop = "1.3.4+298-2c6ff971"
val sbtBloop = "1.3.5"
val gradleBloop = bloop
val mavenBloop = bloop
val mdoc = "2.0.3"
val scalafmt = "2.3.2"
// List of supported Scala versions in SemanticDB. Needs to be manually updated
// for every SemanticDB upgrade.
def supportedScalaVersions =
nonDeprecatedScalaVersions ++ deprecatedScalaVersions
def deprecatedScalaVersions = Seq("2.12.8", "2.12.9", scala211)
def nonDeprecatedScalaVersions = Seq("2.13.0", scala213, scala212)
def guava = "com.google.guava" % "guava" % "28.1-jre"
def lsp4j = "org.eclipse.lsp4j" % "org.eclipse.lsp4j" % "0.8.1"
def dap4j =
"org.eclipse.lsp4j" % "org.eclipse.lsp4j.debug" % "0.8.1"
val coursier = "2.0.0-RC5-3"
}
skip.in(publish) := true
lazy val interfaces = project
.in(file("mtags-interfaces"))
.settings(
moduleName := "mtags-interfaces",
autoScalaLibrary := false,
libraryDependencies ++= List(
V.lsp4j
),
crossVersion := CrossVersion.disabled,
javacOptions in (Compile / doc) ++= List(
"-tag",
"implNote:a:Implementation Note:"
)
)
val genyVersion = Def.setting {
if (scalaVersion.value.startsWith("2.11")) "0.1.6"
else "0.1.8"
}
lazy val mtags = project
.settings(
moduleName := "mtags",
crossVersion := CrossVersion.full,
crossScalaVersions := V.supportedScalaVersions,
scalacOptions ++= crossSetting(
scalaVersion.value,
if211 = List("-Xexperimental", "-Ywarn-unused-import")
),
scalacOptions --= crossSetting(
scalaVersion.value,
if211 = List("-Ywarn-unused:imports")
),
libraryDependencies ++= List(
"com.thoughtworks.qdox" % "qdox" % "2.0.0", // for java mtags
"org.jsoup" % "jsoup" % "1.12.1", // for extracting HTML from javadocs
"org.lz4" % "lz4-java" % "1.7.0", // for streaming hashing when indexing classpaths
"com.lihaoyi" %% "geny" % genyVersion.value,
"org.scala-lang.modules" %% "scala-java8-compat" % "0.9.0",
"org.scalameta" % "semanticdb-scalac-core" % V.scalameta cross CrossVersion.full
),
libraryDependencies ++= {
if (isCI) Nil
// NOTE(olafur) pprint is indispensable for me while developing, I can't
// use println anymore for debugging because pprint.log is 100 times better.
else
crossSetting(
scalaVersion.value,
if211 = List("com.lihaoyi" %% "pprint" % "0.5.4"),
otherwise = List("com.lihaoyi" %% "pprint" % "0.5.6")
)
},
buildInfoPackage := "scala.meta.internal.mtags",
buildInfoKeys := Seq[BuildInfoKey](
"scalaCompilerVersion" -> scalaVersion.value
)
)
.dependsOn(interfaces)
.enablePlugins(BuildInfoPlugin)
lazy val metals = project
.settings(
fork.in(Compile, run) := true,
mainClass.in(Compile) := Some("scala.meta.metals.Main"),
// As a general rule of thumb, we try to keep Scala dependencies to a minimum.
libraryDependencies ++= List(
// =================
// Java dependencies
// =================
// for bloom filters
V.guava,
// for measuring memory footprint
"org.openjdk.jol" % "jol-core" % "0.9",
// for file watching
"io.methvin" % "directory-watcher" % "0.8.0",
// for http client
"io.undertow" % "undertow-core" % "2.0.28.Final",
"org.jboss.xnio" % "xnio-nio" % "3.7.7.Final",
// for persistent data like "dismissed notification"
"org.flywaydb" % "flyway-core" % "6.1.2",
"com.h2database" % "h2" % "1.4.200",
// for starting `sbt bloopInstall` process
"com.zaxxer" % "nuprocess" % "1.2.4",
"net.java.dev.jna" % "jna" % "4.5.2",
"net.java.dev.jna" % "jna-platform" % "4.5.2",
// for token edit-distance used by goto definition
"com.googlecode.java-diff-utils" % "diffutils" % "1.3.0",
// for BSP
"org.scala-sbt.ipcsocket" % "ipcsocket" % "1.0.0",
"ch.epfl.scala" % "bsp4j" % V.bsp,
"ch.epfl.scala" %% "bloop-launcher" % V.bloop,
// for LSP
V.lsp4j,
// for DAP
V.dap4j,
// for producing SemanticDB from Java source files
"com.thoughtworks.qdox" % "qdox" % "2.0.0",
// for finding paths of global log/cache directories
"io.github.soc" % "directories" % "11",
// ==================
// Scala dependencies
// ==================
"org.scala-lang.modules" %% "scala-java8-compat" % "0.9.0",
"org.scalameta" % "mdoc-interfaces" % V.mdoc,
"org.scalameta" %% "scalafmt-dynamic" % V.scalafmt,
// For reading classpaths.
// for fetching ch.epfl.scala:bloop-frontend and other library dependencies
"io.get-coursier" % "interface" % "0.0.16",
// for logging
"com.outr" %% "scribe" % "2.7.10",
"com.outr" %% "scribe-slf4j" % "2.7.10", // needed for flyway database migrations
// for debugging purposes, not strictly needed but nice for productivity
"com.lihaoyi" %% "pprint" % "0.5.6",
// For exporting Pants builds.
"com.lihaoyi" %% "ujson" % "0.8.0",
"ch.epfl.scala" %% "bloop-config" % V.bloop,
// for producing SemanticDB from Scala source files
"org.scalameta" %% "scalameta" % V.scalameta,
"org.scalameta" % "semanticdb-scalac-core" % V.scalameta cross CrossVersion.full
),
buildInfoPackage := "scala.meta.internal.metals",
buildInfoKeys := Seq[BuildInfoKey](
"localSnapshotVersion" -> localSnapshotVersion,
"metalsVersion" -> version.value,
"mdocVersion" -> V.mdoc,
"bspVersion" -> V.bsp,
"bloopVersion" -> V.bloop,
"sbtBloopVersion" -> V.sbtBloop,
"gradleBloopVersion" -> V.gradleBloop,
"mavenBloopVersion" -> V.mavenBloop,
"scalametaVersion" -> V.scalameta,
"semanticdbVersion" -> V.semanticdb,
"scalafmtVersion" -> V.scalafmt,
"supportedScalaVersions" -> V.supportedScalaVersions,
"deprecatedScalaVersions" -> V.deprecatedScalaVersions,
"scala211" -> V.scala211,
"scala212" -> V.scala212,
"scala213" -> V.scala213
)
)
.dependsOn(mtags)
.enablePlugins(BuildInfoPlugin)
lazy val input = project
.in(file("tests/input"))
.settings(
skip.in(publish) := true,
scalacOptions ++= List(
"-P:semanticdb:synthetics:on"
),
libraryDependencies ++= List(
// these projects have macro annotations
"org.scalameta" %% "scalameta" % V.scalameta,
"io.circe" %% "circe-derivation-annotations" % "0.9.0-M5"
),
scalacOptions += "-P:semanticdb:synthetics:on",
addCompilerPlugin(
"org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full
)
)
.disablePlugins(ScalafixPlugin)
lazy val testSettings: Seq[Def.Setting[_]] = List(
skip.in(publish) := true,
fork := true,
testFrameworks := List(new TestFramework("utest.runner.Framework"))
)
lazy val mtest = project
.in(file("tests/mtest"))
.settings(
skip.in(publish) := true,
crossScalaVersions := V.supportedScalaVersions,
libraryDependencies ++= List(
"io.get-coursier" %% "coursier" % V.coursier,
"org.scalameta" %% "testkit" % V.scalameta
) ++ crossSetting(
scalaVersion.value,
if211 = List("com.lihaoyi" %% "utest" % "0.6.8"),
otherwise = List("com.lihaoyi" %% "utest" % "0.7.2")
),
scalacOptions ++= crossSetting(
scalaVersion.value,
if211 = List("-Xexperimental", "-Ywarn-unused-import")
),
scalacOptions --= crossSetting(
scalaVersion.value,
if211 = List("-Ywarn-unused:imports")
),
buildInfoPackage := "tests",
buildInfoObject := "BuildInfoVersions",
buildInfoKeys := Seq[BuildInfoKey](
"scala211" -> V.scala211,
"scala212" -> V.scala212,
"scalaVersion" -> scalaVersion.value
)
)
.dependsOn(mtags)
.enablePlugins(BuildInfoPlugin)
lazy val cross = project
.in(file("tests/cross"))
.settings(
testSettings,
libraryDependencies ++= List(
"com.chuusai" %% "shapeless" % "2.3.3",
"org.typelevel" %% "cats-core" % "2.0.0",
"org.typelevel" %% "simulacrum" % "1.0.0",
"com.olegpy" %% "better-monadic-for" % "0.3.1",
"org.typelevel" %% "kind-projector" % "0.10.3"
) ++ (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, major)) if major <= 12 =>
List("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full)
case _ => Nil
}),
crossScalaVersions := V.nonDeprecatedScalaVersions,
scalacOptions ++= crossSetting(
scalaVersion.value,
if211 = List("-Xexperimental", "-Ywarn-unused-import")
),
scalacOptions --= crossSetting(
scalaVersion.value,
if211 = List("-Ywarn-unused:imports")
)
)
.dependsOn(mtest, mtags)
lazy val unit = project
.in(file("tests/unit"))
.settings(
testSettings,
libraryDependencies ++= List(
"io.get-coursier" %% "coursier" % V.coursier, // for jars
"org.scalameta" %% "testkit" % V.scalameta,
"ch.epfl.scala" %% "bloop-config" % V.bloop,
"com.lihaoyi" %% "utest" % "0.7.2"
),
buildInfoPackage := "tests",
resourceGenerators.in(Compile) += InputProperties.resourceGenerator(input),
compile.in(Compile) :=
compile.in(Compile).dependsOn(compile.in(input, Test)).value,
buildInfoKeys := Seq[BuildInfoKey](
"sourceroot" -> baseDirectory.in(ThisBuild).value,
"targetDirectory" -> target.in(Test).value,
"testResourceDirectory" -> resourceDirectory.in(Test).value,
"scalaVersion" -> scalaVersion.value
)
)
.dependsOn(mtest, metals)
.enablePlugins(BuildInfoPlugin)
def crossPublishLocal(scalaV: String) = Def.task[Unit] {
// Runs `publishLocal` for mtags with `scalaVersion := $scalaV`
val newState = Project
.extract(state.value)
.appendWithSession(
List(
scalaVersion.in(mtags) := scalaV,
useSuperShell.in(ThisBuild) := false
),
state.value
)
val (s, _) = Project
.extract(newState)
.runTask(publishLocal.in(mtags), newState)
}
def publishMtags =
publishLocal
.in(interfaces)
.dependsOn(
crossPublishLocal(V.scala211)
.dependsOn(crossPublishLocal(V.scala213))
)
lazy val slow = project
.in(file("tests/slow"))
.settings(
testSettings,
testOnly.in(Test) := testOnly.in(Test).dependsOn(publishMtags).evaluated,
test.in(Test) := test.in(Test).dependsOn(publishMtags).value
)
.dependsOn(unit)
lazy val bench = project
.in(file("metals-bench"))
.enablePlugins(BuildInfoPlugin)
.settings(
fork.in(run) := true,
skip.in(publish) := true,
moduleName := "metals-bench",
libraryDependencies ++= List(
// for measuring memory usage
"org.spire-math" %% "clouseau" % "0.2.2"
),
buildInfoKeys := Seq[BuildInfoKey](scalaVersion),
buildInfoPackage := "bench"
)
.dependsOn(unit)
.enablePlugins(JmhPlugin)
lazy val docs = project
.in(file("metals-docs"))
.settings(
skip.in(publish) := true,
moduleName := "metals-docs",
mdoc := run.in(Compile).evaluated,
libraryDependencies ++= List(
"org.jsoup" % "jsoup" % "1.12.1"
)
)
.dependsOn(metals)
.enablePlugins(DocusaurusPlugin)