Skip to content

Commit

Permalink
Fix classpath issues with the dotty-sbt-bridge build
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
smarter committed Mar 29, 2019
1 parent 78408e5 commit 8e29d38
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ val `dotty-compiler-bootstrapped` = Build.`dotty-compiler-bootstrapped`
val `dotty-library` = Build.`dotty-library`
val `dotty-library-bootstrapped` = Build.`dotty-library-bootstrapped`
val `dotty-sbt-bridge` = Build.`dotty-sbt-bridge`
val `dotty-sbt-bridge-tests` = Build.`dotty-sbt-bridge-tests`
val `dotty-language-server` = Build.`dotty-language-server`
val `dotty-bench` = Build.`dotty-bench`
val `dotty-bench-bootstrapped` = Build.`dotty-bench-bootstrapped`
Expand Down
34 changes: 27 additions & 7 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -680,19 +680,39 @@ object Build {
case Bootstrapped => `dotty-library-bootstrapped`
}

lazy val `dotty-sbt-bridge` = project.in(file("sbt-bridge")).
dependsOn(dottyCompiler(NonBootstrapped) % Provided).
lazy val `dotty-sbt-bridge` = project.in(file("sbt-bridge/src")).
// We cannot depend on any bootstrapped project to compile the bridge, since the
// bridge is needed to compile these projects.
dependsOn(dottyDoc(NonBootstrapped) % Provided).
settings(commonJavaSettings).
settings(
description := "sbt compiler bridge for Dotty",
libraryDependencies ++= Seq(
Dependencies.`compiler-interface` % Provided,
(Dependencies.`zinc-api-info` % Test).withDottyCompat(scalaVersion.value)
),

sources in Test := Seq(),
scalaSource in Compile := baseDirectory.value,
javaSource in Compile := baseDirectory.value,

// Referring to the other project using a string avoids an infinite loop
// when sbt reads the settings.
test in Test := (test in (LocalProject("dotty-sbt-bridge-tests"), Test)).value,

libraryDependencies += Dependencies.`compiler-interface` % Provided
)

// We use a separate project for the bridge tests since they can only be run
// with the bootstrapped library on the classpath.
lazy val `dotty-sbt-bridge-tests` = project.in(file("sbt-bridge/test")).
dependsOn(dottyCompiler(Bootstrapped) % Test).
settings(commonBootstrappedSettings).
settings(
sources in Compile := Seq(),
scalaSource in Test := baseDirectory.value,
javaSource in Test := baseDirectory.value,

fork in Test := true,
parallelExecution in Test := false
parallelExecution in Test := false,

libraryDependencies += (Dependencies.`zinc-api-info` % Test).withDottyCompat(scalaVersion.value)
)

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

0 comments on commit 8e29d38

Please sign in to comment.