diff --git a/backend/src/main/scala/sbt/internal/inc/BloopComponentCompiler.scala b/backend/src/main/scala/sbt/internal/inc/BloopComponentCompiler.scala index 3be9edd926..126295ac43 100644 --- a/backend/src/main/scala/sbt/internal/inc/BloopComponentCompiler.scala +++ b/backend/src/main/scala/sbt/internal/inc/BloopComponentCompiler.scala @@ -117,7 +117,13 @@ object BloopComponentCompiler { private def compiledBridge(bridgeSources: ModuleID, scalaInstance: ScalaInstance): File = { val raw = new RawCompiler(scalaInstance, ClasspathOptionsUtil.auto, logger) val bridgeJarsOpt = scalaInstance match { - case b: _root_.bloop.ScalaInstance => b.bridgeJarsOpt + case b: _root_.bloop.ScalaInstance => + b.bridgeJarsOpt.foreach { jars => + logger.debug(s"Using user defined bridge jars for Scala ${jars.mkString(",")}")( + DebugFilter.Compilation + ) + } + b.bridgeJarsOpt case _ => None } val zinc = new BloopComponentCompiler(raw, manager, bridgeSources, bridgeJarsOpt, logger) diff --git a/integrations/sbt-bloop/src/main/scala/bloop/integrations/sbt/SbtBloop.scala b/integrations/sbt-bloop/src/main/scala/bloop/integrations/sbt/SbtBloop.scala index 1569cf29b5..ae316521e6 100644 --- a/integrations/sbt-bloop/src/main/scala/bloop/integrations/sbt/SbtBloop.scala +++ b/integrations/sbt-bloop/src/main/scala/bloop/integrations/sbt/SbtBloop.scala @@ -1049,6 +1049,7 @@ object BloopDefaults { val modules = onlyCompilationModules(allModules, classpath).toList if (modules.isEmpty) None else Some(Config.Resolution(modules)) } + val bridge = Keys.scalaCompilerBridgeBinaryJar.value.map(file => List(file.toPath())) // Force source generators on this task manually Keys.managedSources.value @@ -1058,7 +1059,7 @@ object BloopDefaults { val c = Keys.classpathOptions.value val java = Config.Java(javacOptions) val compileSetup = Config.CompileSetup(compileOrder, c.bootLibrary, c.compiler, c.extra, c.autoBoot, c.filterLibrary) - val `scala` = Config.Scala(scalaOrg, scalaName, scalaVersion, scalacOptions, allScalaJars, None, Some(compileSetup), None) + val `scala` = Config.Scala(scalaOrg, scalaName, scalaVersion, scalacOptions, allScalaJars, None, Some(compileSetup), bridge) val resources = Some(bloopResourcesTask.value) val sbt = None // Written by `postGenerate` instead diff --git a/integrations/sbt-bloop/src/sbt-test/sbt-bloop/custom-bridge/build.sbt b/integrations/sbt-bloop/src/sbt-test/sbt-bloop/custom-bridge/build.sbt new file mode 100644 index 0000000000..b02bfe05fa --- /dev/null +++ b/integrations/sbt-bloop/src/sbt-test/sbt-bloop/custom-bridge/build.sbt @@ -0,0 +1,18 @@ +import bloop.integrations.sbt.BloopDefaults + +val foo = project + .in(file(".") / "foo") + .settings( + scalaCompilerBridgeBinaryJar := Some(baseDirectory.value / "fake.jar") + ) + +val checkBloopFiles = taskKey[Unit]("Check bloop file contents") +checkBloopFiles in ThisBuild := { + val bloopDir = Keys.baseDirectory.value./(".bloop") + val fooConfig = bloopDir./("foo.json") + val config = BloopDefaults.unsafeParseConfig(fooConfig.toPath) + val bridgeJars = config.project.scala.get.bridgeJars.map(_.map(_.toString)) + val expectedJars = Some(List((Keys.baseDirectory.value / "foo" / "fake.jar").toString)) + assert(bridgeJars == expectedJars) + +} diff --git a/integrations/sbt-bloop/src/sbt-test/sbt-bloop/custom-bridge/project/plugins.sbt b/integrations/sbt-bloop/src/sbt-test/sbt-bloop/custom-bridge/project/plugins.sbt new file mode 100644 index 0000000000..1a5c0709e6 --- /dev/null +++ b/integrations/sbt-bloop/src/sbt-test/sbt-bloop/custom-bridge/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % sys.props.apply("plugin.version")) diff --git a/integrations/sbt-bloop/src/sbt-test/sbt-bloop/custom-bridge/test b/integrations/sbt-bloop/src/sbt-test/sbt-bloop/custom-bridge/test new file mode 100644 index 0000000000..01c64dc117 --- /dev/null +++ b/integrations/sbt-bloop/src/sbt-test/sbt-bloop/custom-bridge/test @@ -0,0 +1,3 @@ +> foo/bloopGenerate +> foo/test:bloopGenerate +> checkBloopFiles \ No newline at end of file