Skip to content

Commit 442f600

Browse files
committed
Don't export -bootstrapped projects to bsp / bloop
1 parent 58c77c3 commit 442f600

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

project/Build.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ object Build {
283283
)
284284

285285
// Settings used when compiling dotty with a non-bootstrapped dotty
286-
lazy val commonBootstrappedSettings = commonDottySettings ++ Seq(
286+
lazy val commonBootstrappedSettings = commonDottySettings ++ NoBloopExport.settings ++ Seq(
287+
bspEnabled := false,
287288
unmanagedSourceDirectories in Compile += baseDirectory.value / "src-bootstrapped",
288289

289290
version := dottyVersion,
@@ -419,9 +420,11 @@ object Build {
419420
),
420421

421422
// For convenience, change the baseDirectory when running the compiler
422-
baseDirectory in (Compile, run) := baseDirectory.value / "..",
423+
(Compile / forkOptions) := (Compile / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value),
424+
(Compile / run / forkOptions) := (Compile / run / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value),
423425
// And when running the tests
424-
baseDirectory in Test := baseDirectory.value / "..",
426+
(Test / forkOptions) := (Test / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value),
427+
(Test / testOnly / forkOptions) := (Test / testOnly / forkOptions).value.withWorkingDirectory((ThisBuild / baseDirectory).value),
425428

426429
test in Test := {
427430
// Exclude VulpixMetaTests

project/NoBloopExport.scala

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import sbt._
2+
import Keys._
3+
4+
/* With <3 from scala-js */
5+
object NoBloopExport {
6+
private lazy val bloopGenerateKey: Option[TaskKey[Option[File]]] = {
7+
val optBloopKeysClass: Option[Class[_]] = try {
8+
Some(Class.forName("bloop.integrations.sbt.BloopKeys"))
9+
} catch {
10+
case _: ClassNotFoundException => None
11+
}
12+
13+
optBloopKeysClass.map { bloopKeysClass =>
14+
val bloopGenerateGetter = bloopKeysClass.getMethod("bloopGenerate")
15+
bloopGenerateGetter.invoke(null).asInstanceOf[TaskKey[Option[File]]]
16+
}
17+
}
18+
19+
/** Settings to prevent the project from being exported to IDEs. */
20+
lazy val settings: Seq[Setting[_]] = {
21+
bloopGenerateKey match {
22+
case None =>
23+
Nil
24+
case Some(key) =>
25+
Seq(
26+
key in Compile := None,
27+
key in Test := None,
28+
)
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)