Skip to content

Commit a11be8c

Browse files
committed
vf in scalacOptions
**Problem** Compiler options for the compiler plugins ends up capturing the absolute path, specific to the machine. **Solution** This substitutes dollar in scalacOptions with the path.
1 parent 5b55328 commit a11be8c

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ThisBuild / version := {
4646
nightlyVersion match {
4747
case Some(v) => v
4848
case _ =>
49-
if ((ThisBuild / isSnapshot).value) "2.0.0-M2-SNAPSHOT"
49+
if ((ThisBuild / isSnapshot).value) "2.0.0-M3-SNAPSHOT"
5050
else old
5151
}
5252
}

zinc/src/main/scala/sbt/internal/inc/MixedAnalyzingCompiler.scala

+18-4
Original file line numberDiff line numberDiff line change
@@ -146,23 +146,37 @@ final class MixedAnalyzingCompiler(
146146
val pickleJava =
147147
Incremental.isPickleJava(config.currentSetup.options.scalacOptions.toIndexedSeq)
148148

149+
def convertToPath(value: String): String =
150+
if (!value.contains("$")) value
151+
else {
152+
val vf = VirtualFileRef.of(value)
153+
val p = config.converter.toPath(vf)
154+
p.toString()
155+
}
156+
149157
// Compile Scala sources.
150158
def compileScala(): Unit =
151159
if (scalaSrcs.nonEmpty || pickleJava) {
152160
val pickleJarPair = callback.getPickleJarPair.toOption.map(t2 => (t2.get1, t2.get2))
153-
val scalacOpts = pickleJarPair match {
161+
val scalacOpts0 = config.currentSetup.options.scalacOptions.toVector
162+
val scalacOpts1: Vector[String] = scalacOpts0.map { x =>
163+
if (!x.contains("$")) x
164+
else (x.split(":").toVector.map { y =>
165+
y.split(",").toVector.map(convertToPath).mkString(",")
166+
}).mkString(":")
167+
}
168+
val scalacOpts: Vector[String] = pickleJarPair match {
154169
case Some((originalJar, updatesJar)) =>
155170
val path = originalJar.toString
156171
// ^ Path#toString uses '\' on Windows
157172
// but the path could've been specified with '/' in scalacOptions
158173
val fwdSlashPath = path.replace('\\', '/')
159-
config.currentSetup.options.scalacOptions.map {
174+
scalacOpts1.map {
160175
case s if s == path || s == fwdSlashPath => updatesJar.toString
161176
case s => s
162177
}
163-
case _ => config.currentSetup.options.scalacOptions
178+
case _ => scalacOpts1
164179
}
165-
166180
JarUtils.withPreviousJar(output) { (extraClasspath: Seq[Path]) =>
167181
val sources =
168182
if (config.currentSetup.order == Mixed) incSrc

0 commit comments

Comments
 (0)