Scala compiler plugin support

**Problem**
Compiler options for the compiler plugins ends up capturing the absolute path, specific to the machine.

**Solution**
This encodes the plugin paths as virtual paths.
This commit is contained in:
Eugene Yokota 2025-04-28 03:10:44 -04:00
parent 187eb0f584
commit 2fd08caeda
2 changed files with 6 additions and 5 deletions

View File

@ -995,7 +995,7 @@ object Defaults extends BuildCommon {
Vector( Vector(
"-Ypickle-java", "-Ypickle-java",
"-Ypickle-write", "-Ypickle-write",
converter.toPath(earlyOutput.value).toString earlyOutput.value.toString
) ++ old ) ++ old
else old else old
}, },
@ -4221,18 +4221,19 @@ object Classpaths {
given FileConverter = converter given FileConverter = converter
(base * (filter -- excl) +++ (base / config.name).descendantsExcept(filter, excl)).classpath (base * (filter -- excl) +++ (base / config.name).descendantsExcept(filter, excl)).classpath
def autoPlugins( private def autoPlugins(
report: UpdateReport, report: UpdateReport,
internalPluginClasspath: Seq[NioPath], internalPluginClasspath: Seq[NioPath],
isDotty: Boolean isDotty: Boolean
): Seq[String] = )(using conv: FileConverter): Seq[String] =
import sbt.internal.inc.classpath.ClasspathUtil.compilerPlugins import sbt.internal.inc.classpath.ClasspathUtil.compilerPlugins
val pluginClasspath = val pluginClasspath =
report report
.matching(configurationFilter(CompilerPlugin.name)) .matching(configurationFilter(CompilerPlugin.name))
.map(_.toPath) ++ internalPluginClasspath .map(_.toPath) ++ internalPluginClasspath
val plugins = compilerPlugins(pluginClasspath, isDotty) val plugins = compilerPlugins(pluginClasspath, isDotty)
plugins.map("-Xplugin:" + _.toAbsolutePath.toString).toSeq plugins.toVector.map: p =>
"-Xplugin:" + conv.toVirtualFile(p).toString()
private lazy val internalCompilerPluginClasspath: Initialize[Task[Classpath]] = private lazy val internalCompilerPluginClasspath: Initialize[Task[Classpath]] =
(Def (Def

View File

@ -12,7 +12,7 @@ object Dependencies {
// sbt modules // sbt modules
private val ioVersion = nightlyVersion.getOrElse("1.10.4") private val ioVersion = nightlyVersion.getOrElse("1.10.4")
val zincVersion = nightlyVersion.getOrElse("2.0.0-M3") val zincVersion = nightlyVersion.getOrElse("2.0.0-M4")
private val sbtIO = "org.scala-sbt" %% "io" % ioVersion private val sbtIO = "org.scala-sbt" %% "io" % ioVersion