Skip to content

Commit

Permalink
Handle a dependency on JRT as a dummy rt.jar
Browse files Browse the repository at this point in the history
... fixing OutputSpec.
  • Loading branch information
dwijnand committed Jul 13, 2020
1 parent ef5661b commit d254d7d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile with
}
case pf: xsbt.Compat.PlainNioFile =>
// The dependency comes from a class file
binaryDependency(Paths.get(pf.path), binaryClassName)
binaryDependency(pf.nioPath, binaryClassName)
case pf: PlainFile =>
// The dependency comes from a class file
binaryDependency(pf.file.toPath, binaryClassName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package xsbt
import java.nio.file.Path
import scala.reflect.io.{ AbstractFile, Directory }

class PlainNioFile(nioPath: Path) extends AbstractFile {
class PlainNioFile(val nioPath: Path) extends AbstractFile {
import java.nio.file._

assert(nioPath ne null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package xsbt
import java.nio.file.Path
import scala.reflect.io.{ AbstractFile, Directory }

class PlainNioFile(nioPath: Path) extends AbstractFile {
class PlainNioFile(val nioPath: Path) extends AbstractFile {
import java.nio.file._

assert(nioPath ne null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ class MappedFileConverter(rootPaths: Map[String, Path], allowMachinePath: Boolea
case Some((key, rootPath)) =>
MappedVirtualFile(s"$${$key}/${rootPath.relativize(path)}".replace('\\', '/'), rootPaths)
case _ =>
path.getFileName.toString match {
case "rt.jar" => DummyVirtualFile("rt.jar", path)
case _ if allowMachinePath => MappedVirtualFile(s"$path".replace('\\', '/'), rootPaths)
case _ => sys.error(s"$path cannot be mapped using the root paths $rootPaths")
path match {
case p if p.toUri.getScheme == "jrt" => DummyVirtualFile("rt.jar", path)
case p if p.getFileName.toString == "rt.jar" => DummyVirtualFile("rt.jar", path)
case _ if allowMachinePath => MappedVirtualFile(s"$path".replace('\\', '/'), rootPaths)
case _ => sys.error(s"$path cannot be mapped using the root paths $rootPaths")
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions zinc/src/test/scala/sbt/inc/OutputSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class OutputSpec extends BaseCompilerSpec {
assert(!result.analysis.readStamps.getAllSourceStamps.keySet.isEmpty)

val result2 = compiler.doCompileWithStore()

if (sys.props("java.specification.version") == "1.8") // This test fails on Scala 2.13 + JDK 11
assert(!result2.hasModified || sys.props("java.specification.version") != "1.8")
assert(!result2.hasModified)
}

def mkCompiler(baseDir: File, classes: Seq[String]) =
Expand Down

0 comments on commit d254d7d

Please sign in to comment.