diff --git a/backend/src/main/scala/bloop/BloopClassFileManager.scala b/backend/src/main/scala/bloop/BloopClassFileManager.scala index e3f8a299a6..3b1d00264e 100644 --- a/backend/src/main/scala/bloop/BloopClassFileManager.scala +++ b/backend/src/main/scala/bloop/BloopClassFileManager.scala @@ -154,13 +154,15 @@ final class BloopClassFileManager( val toBeBackedUp = (classes ++ invalidatedExtraCompileProducts).filter(c => !movedFiles.contains(c) && !generatedFiles(c) ) - for (c <- toBeBackedUp) - if (c.exists) - movedFiles.put(c, move(c)).foreach(move) + for { + c <- toBeBackedUp + if c.exists() + } movedFiles.put(c, move(c)).foreach(move) - classes.foreach { f => - if (f.exists()) f.delete() - } + for { + f <- classes + if f.exists() + } f.delete() allInvalidatedExtraCompileProducts.++=(invalidatedExtraCompileProducts) } @@ -227,13 +229,12 @@ final class BloopClassFileManager( */ for { (orig, tmp) <- movedFiles + if tmp.exists } { - if (tmp.exists) { - if (!orig.getParentFile.exists) { - Files.createDirectory(orig.getParentFile.toPath()) - } - Files.move(tmp.toPath(), orig.toPath()) + if (!orig.getParentFile.exists) { + Files.createDirectory(orig.getParentFile.toPath()) } + Files.move(tmp.toPath(), orig.toPath()) } backupDir.toFile().delete() () diff --git a/backend/src/main/scala/bloop/BloopClasspathEntryLookup.scala b/backend/src/main/scala/bloop/BloopClasspathEntryLookup.scala index a99167c828..b2197c16f2 100644 --- a/backend/src/main/scala/bloop/BloopClasspathEntryLookup.scala +++ b/backend/src/main/scala/bloop/BloopClasspathEntryLookup.scala @@ -33,14 +33,15 @@ final class BloopClasspathEntryLookup( } override def definesClass(entry: VirtualFile): DefinesClass = { - val file = converter.toPath(entry).toFile() + val path = converter.toPath(entry) + val file = path.toFile() if (!file.exists) FalseDefinesClass else { classpathHashes.find(fh => fh.file() == file) match { case None => FalseDefinesClass case Some(entryHash) => def computeDefinesClassForJar = { - if (!ClasspathUtil.isArchive(file.toPath(), contentFallback = true)) FalseDefinesClass + if (!ClasspathUtil.isArchive(path, contentFallback = true)) FalseDefinesClass else new JarDefinesClass(file) } diff --git a/backend/src/main/scala/bloop/Compiler.scala b/backend/src/main/scala/bloop/Compiler.scala index dbbbbc4046..af2e504aeb 100644 --- a/backend/src/main/scala/bloop/Compiler.scala +++ b/backend/src/main/scala/bloop/Compiler.scala @@ -287,7 +287,6 @@ object Compiler { def getCompilationOptions(inputs: CompileInputs): CompileOptions = { // Sources are all files val sources = inputs.sources.map(path => converter.toVirtualFile(path.underlying)) - val classpath = inputs.classpath.map(path => converter.toVirtualFile(path.underlying)) val optionsWithoutFatalWarnings = inputs.scalacOptions.flatMap { option => if (option != "-Xfatal-warnings") List(option) diff --git a/backend/src/main/scala/bloop/CompilerCache.scala b/backend/src/main/scala/bloop/CompilerCache.scala index 3949f9de8a..4a44f8d638 100644 --- a/backend/src/main/scala/bloop/CompilerCache.scala +++ b/backend/src/main/scala/bloop/CompilerCache.scala @@ -206,7 +206,7 @@ final class CompilerCache( BloopForkedJavaUtils.launch( javaHome, "javac", - sources.map(converter.toPath(_).toFile()), + sources.map(converter.toPath(_)), options, log, reporter @@ -332,7 +332,9 @@ final class CompilerCache( zincManager match { case m: bloop.BloopClassFileManager => m.invalidatedClassFilesSet // Bloop uses it's own classfile manager so this should not happen - case _ => new HashSet[File]() + case _ => + logger.warn("Could not find BloopClassfileManager that is needed for invaldiation.") + new HashSet[File]() } } diff --git a/backend/src/main/scala/sbt/internal/inc/BloopComponentCompiler.scala b/backend/src/main/scala/sbt/internal/inc/BloopComponentCompiler.scala index 87b1399eb2..7fd2438a55 100644 --- a/backend/src/main/scala/sbt/internal/inc/BloopComponentCompiler.scala +++ b/backend/src/main/scala/sbt/internal/inc/BloopComponentCompiler.scala @@ -63,10 +63,8 @@ object BloopComponentCompiler { } val (isDotty, organization, version) = scalaInstance match { - case instance: BloopScalaInstance => - if (instance.isDotty) (true, instance.organization, instance.version) - else (false, "org.scala-sbt", latestVersion) - case instance: ScalaInstance => (false, "org.scala-sbt", latestVersion) + case instance: BloopScalaInstance if instance.isDotty => (true, instance.organization, instance.version) + case _ => (false, "org.scala-sbt", latestVersion) } val bridgeId = compilerBridgeId(scalaInstance.version) @@ -375,13 +373,13 @@ private[inc] class BloopComponentCompiler( logger.debug(s"Sources from bloop bridge: $regularSourceContents") - val mergedJar = Files.createTempFile(HydraSupport.bridgeNamePrefix, "merged").toFile + val mergedJar = Files.createTempFile(HydraSupport.bridgeNamePrefix, "merged") logger.debug(s"Merged jar destination: $mergedJar") val allSourceContents = (hydraSourceContents ++ regularSourceContents).map(s => s -> relativize(tempDir, s).get) - zip(allSourceContents.toSeq, mergedJar, time = None) - Right(Vector(mergedJar.toPath())) + zip(allSourceContents.toSeq, mergedJar.toFile(), time = None) + Right(Vector(mergedJar)) } case Right(Seq()) => diff --git a/backend/src/main/scala/sbt/internal/inc/javac/BloopForkedJavaUtils.scala b/backend/src/main/scala/sbt/internal/inc/javac/BloopForkedJavaUtils.scala index 178ed3225f..f86d78ef6c 100644 --- a/backend/src/main/scala/sbt/internal/inc/javac/BloopForkedJavaUtils.scala +++ b/backend/src/main/scala/sbt/internal/inc/javac/BloopForkedJavaUtils.scala @@ -3,12 +3,13 @@ package sbt.internal.inc.javac import java.io.File import xsbti.Logger import xsbti.Reporter +import java.nio.file.Path object BloopForkedJavaUtils { def launch( javac: Option[File], binaryName: String, - sources: Seq[File], + sources: Seq[Path], options: Seq[String], log: Logger, reporter: Reporter @@ -16,7 +17,7 @@ object BloopForkedJavaUtils { def normalizeSlash(s: String) = s.replace(File.separatorChar, '/') val (jArgs, nonJArgs) = options.partition(_.startsWith("-J")) - val allArguments = nonJArgs ++ sources.map(_.getAbsolutePath) + val allArguments = nonJArgs ++ sources.map(_.toAbsolutePath().toString()) val exe = javac match { case None => binaryName