Skip to content

Commit

Permalink
Merge pull request #2484 from tgodzik/add-abt-bridge
Browse files Browse the repository at this point in the history
improvement: Use sbt bridge defined by the user
  • Loading branch information
tgodzik authored Oct 28, 2024
2 parents b551db3 + a9d25ff commit ede1b04
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % sys.props.apply("plugin.version"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> foo/bloopGenerate
> foo/test:bloopGenerate
> checkBloopFiles

0 comments on commit ede1b04

Please sign in to comment.