Skip to content

Commit f06a249

Browse files
smarterOlivierBlanvillain
authored andcommitted
Fix classpath issues with the dotty-sbt-bridge build
When compiling and running the tests for the bridge, we should have the bootstrapped library on the classpath since this is what people will actually use in the end. This is tricky to do since the bridge itself cannot be compiled with anything bootstrapped on the classpath since the bootstrapped projects need the bridge to be compiled ! We sidestep this issue by using two separate projects for the bridge and its tests.
1 parent b7a3936 commit f06a249

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ val `dotty-compiler-bootstrapped` = Build.`dotty-compiler-bootstrapped`
88
val `dotty-library` = Build.`dotty-library`
99
val `dotty-library-bootstrapped` = Build.`dotty-library-bootstrapped`
1010
val `dotty-sbt-bridge` = Build.`dotty-sbt-bridge`
11+
val `dotty-sbt-bridge-tests` = Build.`dotty-sbt-bridge-tests`
1112
val `dotty-language-server` = Build.`dotty-language-server`
1213
val `dotty-bench` = Build.`dotty-bench`
1314
val `dotty-bench-bootstrapped` = Build.`dotty-bench-bootstrapped`

project/Build.scala

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -680,19 +680,39 @@ object Build {
680680
case Bootstrapped => `dotty-library-bootstrapped`
681681
}
682682

683-
lazy val `dotty-sbt-bridge` = project.in(file("sbt-bridge")).
684-
dependsOn(dottyCompiler(NonBootstrapped) % Provided).
683+
lazy val `dotty-sbt-bridge` = project.in(file("sbt-bridge/src")).
684+
// We cannot depend on any bootstrapped project to compile the bridge, since the
685+
// bridge is needed to compile these projects.
685686
dependsOn(dottyDoc(NonBootstrapped) % Provided).
686687
settings(commonJavaSettings).
687688
settings(
688689
description := "sbt compiler bridge for Dotty",
689-
libraryDependencies ++= Seq(
690-
Dependencies.`compiler-interface` % Provided,
691-
(Dependencies.`zinc-api-info` % Test).withDottyCompat(scalaVersion.value)
692-
),
690+
691+
sources in Test := Seq(),
692+
scalaSource in Compile := baseDirectory.value,
693+
javaSource in Compile := baseDirectory.value,
694+
695+
// Referring to the other project using a string avoids an infinite loop
696+
// when sbt reads the settings.
697+
test in Test := (test in (LocalProject("dotty-sbt-bridge-tests"), Test)).value,
698+
699+
libraryDependencies += Dependencies.`compiler-interface` % Provided
700+
)
701+
702+
// We use a separate project for the bridge tests since they can only be run
703+
// with the bootstrapped library on the classpath.
704+
lazy val `dotty-sbt-bridge-tests` = project.in(file("sbt-bridge/test")).
705+
dependsOn(dottyCompiler(Bootstrapped) % Test).
706+
settings(commonBootstrappedSettings).
707+
settings(
708+
sources in Compile := Seq(),
709+
scalaSource in Test := baseDirectory.value,
710+
javaSource in Test := baseDirectory.value,
693711

694712
fork in Test := true,
695-
parallelExecution in Test := false
713+
parallelExecution in Test := false,
714+
715+
libraryDependencies += (Dependencies.`zinc-api-info` % Test).withDottyCompat(scalaVersion.value)
696716
)
697717

698718
lazy val `dotty-language-server` = project.in(file("language-server")).

0 commit comments

Comments
 (0)