Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: Use sbt bridge defined by the user #2484

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1025,6 +1025,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 @@ -1034,7 +1035,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
Loading