forked from scalameta/metals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
677 lines (641 loc) Β· 22.5 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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
import scala.collection.mutable
import scala.sys.process._
import Developers._
import Tests._
Global / onChangedBuildSource := ReloadOnSourceChanges
def localSnapshotVersion = "0.11.7-SNAPSHOT"
def isCI = System.getenv("CI") != null
def isScala211(v: Option[(Long, Long)]): Boolean = v.contains((2, 11))
def isScala212(v: Option[(Long, Long)]): Boolean = v.contains((2, 12))
def isScala213(v: Option[(Long, Long)]): Boolean = v.contains((2, 13))
def isScala2(v: Option[(Long, Long)]): Boolean = v.exists(_._1 == 2)
def isScala3(v: Option[(Long, Long)]): Boolean = v.exists(_._1 == 3)
def crossSetting[A](
scalaVersion: String,
if211: List[A] = Nil,
if213: List[A] = Nil,
if3: List[A] = Nil,
if2: List[A] = Nil
): List[A] =
CrossVersion.partialVersion(scalaVersion) match {
case partialVersion if isScala211(partialVersion) => if211 ::: if2
case partialVersion if isScala212(partialVersion) => if2
case partialVersion if isScala213(partialVersion) => if2 ::: if213
case partialVersion if isScala3(partialVersion) => if3
case _ => Nil
}
logo := Welcome.logo
usefulTasks := Welcome.tasks
ThisBuild / scalafixScalaBinaryVersion := scalaBinaryVersion.value
inThisBuild(
List(
version ~= { dynVer =>
if (isCI) dynVer
else localSnapshotVersion // only for local publishing
},
scalaVersion := V.scala213,
crossScalaVersions := List(V.scala213),
scalacOptions ++= List(
"-target:jvm-1.8",
"-Yrangepos"
),
scalafixDependencies += "com.github.liancheng" %% "organize-imports" % V.organizeImportRule,
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 := metalsDevs,
testFrameworks := List(),
resolvers += Resolver.sonatypeRepo("public"),
resolvers += Resolver.sonatypeRepo("snapshot"),
dependencyOverrides += V.guava,
// faster publishLocal:
packageDoc / publishArtifact := sys.env.contains("CI"),
packageSrc / publishArtifact := sys.env.contains("CI"),
resolvers += Resolver.bintrayRepo("scalacenter", "releases")
)
)
Global / onLoad ~= { 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 --diff-branch main
|git diff --exit-code
|""".stripMargin.getBytes()
)
prePush.toFile.setExecutable(true)
}
old
}
Global / cancelable := true
Global / excludeLintKeys += scalafixConfig
crossScalaVersions := Nil
addCommandAlias("scalafixAll", "all compile:scalafix test:scalafix")
addCommandAlias("scalafixCheck", "; scalafix --check ; test:scalafix --check")
addCommandAlias(
"downloadDependencies",
"+publishLocal; metals/runMain scala.meta.metals.DownloadDependencies "
)
def configureMtagsScalaVersionDynamically(
state: State,
scalaV: String
): State = {
val scalaVersionSettings =
List(
mtest / scalaVersion := scalaV,
mtags / scalaVersion := scalaV,
cross / scalaVersion := scalaV
)
val extracted = Project.extract(state)
extracted
.appendWithSession(
scalaVersionSettings,
state
)
}
def crossTestDyn(state: State, scalaV: String): State = {
val configured = configureMtagsScalaVersionDynamically(state, scalaV)
val (out, _) =
Project
.extract(configured)
.runTask(cross / Test / test, configured)
out
}
commands ++= Seq(
Command.command("save-expect") { s =>
"unit/test:runMain tests.SaveExpect" :: s
},
Command.command("quick-publish-local") { s =>
val publishMtags = V.quickPublishScalaVersions.foldLeft(s) { case (st, v) =>
runMtagsPublishLocal(st, v, localSnapshotVersion)
}
"interfaces/publishLocal" :: s"++${V.scala213} metals/publishLocal" :: publishMtags
},
Command.command("cross-test-latest-nightly") { s =>
val max =
if (V.nightlyScala3DottyVersions.nonEmpty)
Option(V.nightlyScala3DottyVersions.max)
else None
max match {
case Some(latest) => crossTestDyn(s, latest.toString)
case None =>
println("No nightly versions was found. Skipping cross/test")
s
}
},
Command.single("test-mtags-dyn") { (s, scalaV) =>
crossTestDyn(s, scalaV)
}
)
// -Xlint is unusable because of
// https://github.com/scala/bug/issues/10448
def lintingOptions(scalaVersion: String) = {
val unused213 = "-Wunused"
val unused3 = "-Wunused:all"
val common = List(
// desugaring of for yield caused pattern var to complain
// https://github.com/scala/bug/issues/10287
"-Wconf:msg=parameter value .+ in anonymous function:silent",
// silence unused parameters in mtags
"-Wconf:src=*.ScaladocParser.scala&msg=parameter value (pos|message) in method reportError:silent",
"-Wconf:src=*.Completions.scala&msg=parameter value (member|m) in method (isCandidate|isPrioritized):silent",
"-Wconf:src=*.JavaMtags.scala&msg=parameter value (ctor|method) in method (visitConstructor|visitMethod):silent",
"-Wconf:src=*.MtagsIndexer.scala&msg=parameter value owner in method visitOccurrence:silent",
// silence "The outer reference in this type test cannot be checked at run time."
"-Wconf:src=.*(CompletionProvider|ArgCompletions|Completions|Keywords|IndentOnPaste).scala&msg=The outer reference:silent",
"-Wconf:src=*.BasePCSuite.scala&msg=parameter value (scalaVersion|classpath) in method (extraDependencies|scalacOptions):silent"
)
// -Wconf is available only from 2.13.2
val commonFiltered =
if (scalaVersion == "2.13.1") common.filterNot(_.startsWith("-Wconf"))
else common
crossSetting(
scalaVersion,
if213 = unused213 :: commonFiltered,
if3 = unused3 :: Nil,
if211 = List("-Ywarn-unused-import")
)
}
val sharedSettings = List(
libraryDependencies ++= crossSetting(
scalaVersion.value,
if2 = List(
compilerPlugin(
"org.scalameta" % "semanticdb-scalac" % V.scalameta cross CrossVersion.full
)
)
),
scalacOptions ++= crossSetting(
scalaVersion.value,
if3 = List(
"-language:implicitConversions",
"-Xtarget:8",
"-Xsemanticdb"
),
if211 = List("-Xexperimental")
),
scalacOptions --= crossSetting(
scalaVersion.value,
if3 = List("-Yrangepos", "-target:jvm-1.8")
),
scalacOptions ++= lintingOptions(scalaVersion.value)
)
publish / skip := true
lazy val interfaces = project
.in(file("mtags-interfaces"))
.settings(
moduleName := "mtags-interfaces",
autoScalaLibrary := false,
crossPaths := false,
libraryDependencies ++= List(
V.lsp4j
),
crossVersion := CrossVersion.disabled,
Compile / doc / javacOptions ++= List(
"-tag",
"implNote:a:Implementation Note:"
)
)
def multiScalaDirectories(root: File, scalaVersion: String) = {
val base = root / "src" / "main"
val result = mutable.ListBuffer.empty[File]
val partialVersion = CrossVersion.partialVersion(scalaVersion)
partialVersion.collect { case (major, minor) =>
result += base / s"scala-$major.$minor"
}
if (isScala2(partialVersion)) {
result += base / "scala-2"
}
if (isScala3(partialVersion)) {
result += base / "scala-3"
}
result += base / s"scala-$scalaVersion"
result.toList
}
val mtagsSettings = List(
crossScalaVersions := {
V.supportedScalaVersions ++ V.nightlyScala3Versions
},
crossTarget := target.value / s"scala-${scalaVersion.value}",
crossVersion := CrossVersion.full,
Compile / unmanagedSourceDirectories ++= multiScalaDirectories(
(ThisBuild / baseDirectory).value / "mtags",
scalaVersion.value
),
// @note needed to deal with issues with dottyDoc
Compile / doc / sources := Seq.empty,
libraryDependencies ++= Seq(
"com.lihaoyi" %% "geny" % V.genyVersion,
"com.thoughtworks.qdox" % "qdox" % V.qdox, // for java mtags
"org.scala-lang.modules" %% "scala-java8-compat" % V.java8Compat,
"org.jsoup" % "jsoup" % V.jsoup // for extracting HTML from javadocs
),
libraryDependencies ++= crossSetting(
scalaVersion.value,
if2 = List(
// for token edit-distance used by goto definition
"com.googlecode.java-diff-utils" % "diffutils" % "1.3.0",
"org.scalameta" % "semanticdb-scalac-core" % V.scalameta cross CrossVersion.full
),
if3 = List(
"org.scala-lang" %% "scala3-compiler" % scalaVersion.value,
("org.scalameta" %% "scalameta" % V.scalameta)
.cross(CrossVersion.for3Use2_13)
.exclude("org.scala-lang", "scala-reflect")
.exclude("org.scala-lang", "scala-compiler")
.exclude(
"com.lihaoyi",
"geny_2.13"
) // avoid 2.13 and 3 on the classpath since we rely on it directly
.exclude(
"com.lihaoyi",
"sourcecode_2.13"
) // avoid 2.13 and 3 on the classpath since it comes in via pprint
)
),
libraryDependencies ++= List("org.lz4" % "lz4-java" % "1.8.0"),
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 {
List("com.lihaoyi" %% "pprint" % V.pprint)
}
},
buildInfoPackage := "scala.meta.internal.mtags",
buildInfoKeys := Seq[BuildInfoKey](
"scalaCompilerVersion" -> scalaVersion.value
)
)
lazy val mtags3 = project
.in(file(".mtags"))
.settings(
Compile / unmanagedSourceDirectories := Seq(),
sharedSettings,
mtagsSettings,
Compile / unmanagedSourceDirectories += (ThisBuild / baseDirectory).value / "mtags" / "src" / "main" / "scala",
moduleName := "mtags3",
scalaVersion := V.scala3,
target := (ThisBuild / baseDirectory).value / "mtags" / "target" / "target3",
publish / skip := true,
scalafixConfig := Some(
(ThisBuild / baseDirectory).value / ".scalafix3.conf"
)
)
.dependsOn(interfaces)
.enablePlugins(BuildInfoPlugin)
lazy val mtags = project
.settings(
sharedSettings,
mtagsSettings,
moduleName := "mtags"
)
.dependsOn(interfaces)
.enablePlugins(BuildInfoPlugin)
lazy val metals = project
.settings(
sharedSettings,
Compile / run / fork := true,
Compile / mainClass := 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,
"com.geirsson" %% "metaconfig-core" % "0.10.0",
// for measuring memory footprint
"org.openjdk.jol" % "jol-core" % "0.16",
// for file watching
"com.swoval" % "file-tree-views" % "2.1.9",
// for http client
"io.undertow" % "undertow-core" % "2.2.18.Final",
"org.jboss.xnio" % "xnio-nio" % "3.8.7.Final",
// for persistent data like "dismissed notification"
"org.flywaydb" % "flyway-core" % "8.5.12",
"com.h2database" % "h2" % "2.1.214",
// for BSP
"org.scala-sbt.ipcsocket" % "ipcsocket" % "1.4.0",
"ch.epfl.scala" % "bsp4j" % V.bsp,
"ch.epfl.scala" %% "bloop-launcher" % V.bloopNightly,
// for LSP
V.lsp4j,
// for DAP
V.dap4j,
// for finding paths of global log/cache directories
"dev.dirs" % "directories" % "26",
// for Java formatting
"org.eclipse.jdt" % "org.eclipse.jdt.core" % "3.25.0" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.ant.core" % "3.5.500" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.compare.core" % "3.6.600" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.core.commands" % "3.9.500" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.core.contenttype" % "3.7.500" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.core.expressions" % "3.6.500" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.core.filesystem" % "1.7.500" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.core.jobs" % "3.10.500" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.core.resources" % "3.13.500" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.core.runtime" % "3.16.0" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.core.variables" % "3.4.600" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.equinox.app" % "1.4.300" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.equinox.common" % "3.10.600" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.equinox.preferences" % "3.7.600" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.equinox.registry" % "3.8.600" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.osgi" % "3.15.0" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.team.core" % "3.8.700" exclude ("*", "*"),
"org.eclipse.platform" % "org.eclipse.text" % "3.9.0" exclude ("*", "*"),
// ==================
// Scala dependencies
// ==================
"org.scalameta" % "mdoc-interfaces" % V.mdoc,
"org.scalameta" %% "scalafmt-dynamic" % V.scalafmt,
"ch.epfl.scala" % "scalafix-interfaces" % V.scalafix,
// For reading classpaths.
// for fetching ch.epfl.scala:bloop-frontend and other library dependencies
"io.get-coursier" % "interface" % V.coursierInterfaces,
// for logging
"com.outr" %% "scribe" % V.scribe,
"com.outr" %% "scribe-file" % V.scribe,
"com.outr" %% "scribe-slf4j" % V.scribe, // needed for flyway database migrations
// for JSON formatted doctor
"com.lihaoyi" %% "ujson" % "2.0.0",
// For remote language server
"com.lihaoyi" %% "requests" % "0.7.1",
// for producing SemanticDB from Scala source files
"org.scalameta" %% "scalameta" % V.scalameta,
"org.scalameta" % "semanticdb-scalac-core" % V.scalameta cross CrossVersion.full,
// For starting Ammonite
"io.github.alexarchambault.ammonite" %% "ammonite-runner" % "0.3.2",
"org.scala-lang.modules" %% "scala-xml" % "2.1.0",
"org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4"
),
buildInfoPackage := "scala.meta.internal.metals",
buildInfoKeys := Seq[BuildInfoKey](
"localSnapshotVersion" -> localSnapshotVersion,
"metalsVersion" -> version.value,
"mdocVersion" -> V.mdoc,
"bspVersion" -> V.bsp,
"sbtVersion" -> sbtVersion.value,
"bloopVersion" -> V.bloop,
"bloopNightlyVersion" -> V.bloop,
"sbtBloopVersion" -> V.sbtBloop,
"gradleBloopVersion" -> V.gradleBloop,
"mavenBloopVersion" -> V.mavenBloop,
"scalametaVersion" -> V.scalameta,
"semanticdbVersion" -> V.semanticdb,
"javaSemanticdbVersion" -> V.javaSemanticdb,
"scalafmtVersion" -> V.scalafmt,
"ammoniteVersion" -> V.ammonite,
"organizeImportVersion" -> V.organizeImportRule,
"millVersion" -> V.mill,
"debugAdapterVersion" -> V.debugAdapter,
"sbtJdiToolsVersion" -> V.sbtJdiTools,
"supportedScalaVersions" -> V.supportedScalaVersions,
"supportedScala2Versions" -> V.scala2Versions,
"minimumSupportedSbtVersion" -> V.minimumSupportedSbtVersion,
"supportedScala3Versions" -> V.scala3Versions,
"supportedScalaBinaryVersions" -> V.supportedScalaBinaryVersions,
"deprecatedScalaVersions" -> V.deprecatedScalaVersions,
"nonDeprecatedScalaVersions" -> V.nonDeprecatedScalaVersions,
"scala211" -> V.scala211,
"scala212" -> V.scala212,
"ammonite212" -> V.ammonite212Version,
"ammonite213" -> V.ammonite213Version,
"scala213" -> V.scala213,
"scala3" -> V.scala3
)
)
.dependsOn(mtags)
.enablePlugins(BuildInfoPlugin)
lazy val `sbt-metals` = project
.settings(
buildInfoPackage := "scala.meta.internal.sbtmetals",
buildInfoKeys := Seq[BuildInfoKey](
"semanticdbVersion" -> V.semanticdb,
"supportedScala2Versions" -> V.scala2Versions,
"javaSemanticdbVersion" -> V.javaSemanticdb
),
scalaVersion := V.scala212,
scriptedLaunchOpts ++= Seq(s"-Dplugin.version=${version.value}")
)
.enablePlugins(BuildInfoPlugin, SbtPlugin)
.disablePlugins(ScalafixPlugin)
lazy val input = project
.in(file("tests/input"))
.settings(
sharedSettings,
publish / skip := true,
libraryDependencies ++= List(
// these projects have macro annotations
"org.scalameta" %% "scalameta" % V.scalameta,
"io.circe" %% "circe-derivation-annotations" % "0.13.0-M5"
),
scalacOptions ++= Seq("-P:semanticdb:synthetics:on", "-Ymacro-annotations"),
scalacOptions ~= { options =>
options.filter(_ != "-Wunused")
}
)
.disablePlugins(ScalafixPlugin)
lazy val input3 = project
.in(file("tests/input3"))
.settings(
sharedSettings,
scalaVersion := V.scala3,
publish / skip := true
)
.disablePlugins(ScalafixPlugin)
lazy val testSettings: Seq[Def.Setting[_]] = List(
Test / parallelExecution := false,
publish / skip := true,
fork := true,
testFrameworks := List(TestFrameworks.MUnit),
Test / testOptions ++= {
if (isCI) {
// Enable verbose logging using sbt loggers in CI.
List(Tests.Argument(TestFrameworks.MUnit, "+l", "--verbose", "-F"))
} else {
Nil
}
}
)
def runMtagsPublishLocal(
state: State,
scalaV: String,
projectV: String
): State = {
val newState = Project
.extract(state)
.appendWithSession(
List(
mtags / scalaVersion := scalaV,
ThisBuild / version := projectV,
ThisBuild / useSuperShell := false
),
state
)
val (s, _) = Project
.extract(newState)
.runTask(mtags / publishLocal, newState)
s
}
def crossPublishLocal(scalaV: String) =
Def.task[Unit] {
val versionValue = (ThisBuild / version).value
// Runs `publishLocal` for mtags with `scalaVersion := $scalaV`
runMtagsPublishLocal(state.value, scalaV, versionValue)
}
def publishAllMtags(
all: List[String]
): sbt.Def.Initialize[sbt.Task[Unit]] = {
all match {
case Nil =>
throw new Exception("The Scala versions list cannot be empty")
case head :: Nil =>
crossPublishLocal(head)
case head :: tl =>
crossPublishLocal(head).dependsOn(publishAllMtags(tl))
}
}
def publishBinaryMtags =
(interfaces / publishLocal)
.dependsOn(
publishAllMtags(V.quickPublishScalaVersions)
)
lazy val mtest = project
.in(file("tests/mtest"))
.settings(
testSettings,
sharedSettings,
libraryDependencies ++= List(
"org.scalameta" %% "munit" % V.munit,
"io.get-coursier" % "interface" % V.coursierInterfaces
),
buildInfoPackage := "tests",
buildInfoObject := "BuildInfoVersions",
buildInfoKeys := Seq[BuildInfoKey](
"scala211" -> V.scala211,
"scala212" -> V.scala212,
"scala213" -> V.scala213,
"scala3" -> V.scala3,
"scala2Versions" -> V.scala2Versions,
"scala3Versions" -> (V.scala3Versions ++ V.nightlyScala3Versions),
"scala2Versions" -> V.scala2Versions,
"scalaVersion" -> scalaVersion.value,
"kindProjector" -> V.kindProjector,
"betterMonadicFor" -> V.betterMonadicFor
),
crossScalaVersions := V.nonDeprecatedScalaVersions,
Compile / unmanagedSourceDirectories ++= multiScalaDirectories(
(ThisBuild / baseDirectory).value / "tests" / "mtest",
scalaVersion.value
)
)
.dependsOn(mtags)
.enablePlugins(BuildInfoPlugin)
lazy val cross = project
.in(file("tests/cross"))
.settings(
testSettings,
sharedSettings,
crossScalaVersions := V.nonDeprecatedScalaVersions
)
.dependsOn(mtest, mtags)
def isInTestShard(name: String, logger: Logger): Boolean = {
val groupIndex = TestGroups.testGroups.indexWhere(group => group(name))
if (groupIndex == -1) {
logger.warn(
s"""|Test is not contained in a shard: $name
|It will be executed by default in the first shard.
|Please add it to "project/TestGroups.scala". """.stripMargin
)
}
if (!isCI) {
true
} else {
val groupId = Math.max(0, groupIndex) + 1
System.getenv("TEST_SHARD").toInt == groupId
}
}
lazy val unit = project
.in(file("tests/unit"))
.settings(
testSettings,
Test / testOptions ++= Seq(
Tests.Filter(name => isInTestShard(name, sLog.value))
),
sharedSettings,
Test / javaOptions += "-Xmx2G",
libraryDependencies ++= List(
"io.get-coursier" %% "coursier" % V.coursier, // for jars
"ch.epfl.scala" %% "bloop-config" % V.bloop,
"org.scalameta" %% "munit" % V.munit,
// The dependencies listed below are only listed so Scala Steward
// will pick them up and update them. They aren't actually used.
"com.lihaoyi" %% "ammonite-util" % V.ammonite intransitive (),
"org.typelevel" % "kind-projector" % V.kindProjector cross CrossVersion.full intransitive (),
"com.olegpy" %% "better-monadic-for" % V.betterMonadicFor intransitive (),
"com.lihaoyi" % "mill-contrib-testng" % V.mill intransitive ()
),
buildInfoPackage := "tests",
Compile / resourceGenerators += InputProperties
.resourceGenerator(input, input3),
Compile / compile :=
(Compile / compile)
.dependsOn(
input / Test / compile,
input3 / Test / compile
)
.value,
buildInfoKeys := Seq[BuildInfoKey](
"sourceroot" -> (ThisBuild / baseDirectory).value,
"targetDirectory" -> (Test / target).value,
"testResourceDirectory" -> (Test / resourceDirectory).value,
"scalaVersion" -> scalaVersion.value
)
)
.dependsOn(mtest, metals)
.enablePlugins(BuildInfoPlugin)
lazy val slow = project
.in(file("tests/slow"))
.settings(
testSettings,
sharedSettings,
Test / testOnly := (Test / testOnly)
.dependsOn((`sbt-metals` / publishLocal), publishBinaryMtags)
.evaluated,
Test / test := (Test / test)
.dependsOn(`sbt-metals` / publishLocal, publishBinaryMtags)
.value
)
.dependsOn(unit)
lazy val bench = project
.in(file("metals-bench"))
.enablePlugins(BuildInfoPlugin)
.settings(
sharedSettings,
run / fork := true,
publish / skip := true,
moduleName := "metals-bench",
buildInfoKeys := Seq[BuildInfoKey](scalaVersion),
buildInfoPackage := "bench",
Jmh / bspEnabled := false
)
.dependsOn(unit)
.enablePlugins(JmhPlugin)
lazy val docs = project
.in(file("metals-docs"))
.settings(
sharedSettings,
publish / skip := true,
moduleName := "metals-docs",
mdoc := (Compile / run).evaluated,
dependencyOverrides += "com.lihaoyi" %% "pprint" % "0.6.6"
)
.dependsOn(metals)
.enablePlugins(DocusaurusPlugin)