Refactor createBootClasspath to avoid work when sun.boot.class.path is present

This commit is contained in:
Jason Zaugg 2017-11-01 13:36:23 +10:00
parent 5a1e832a13
commit aac97476ce
1 changed files with 8 additions and 7 deletions

View File

@ -45,13 +45,14 @@ final class CompilerArguments(scalaInstance: xsbti.compile.ScalaInstance, cp: xs
/** Add the correct Scala library jar to the boot classpath if `addLibrary` is true.*/ /** Add the correct Scala library jar to the boot classpath if `addLibrary` is true.*/
def createBootClasspath(addLibrary: Boolean) = def createBootClasspath(addLibrary: Boolean) =
{ {
def findBoot: String = { def findBoot: String =
import scala.collection.JavaConverters._ {
System.getProperties.asScala.iterator.collectFirst { import scala.collection.JavaConverters._
case (k, v) if k.endsWith(".boot.class.path") => v System.getProperties.asScala.iterator.collectFirst {
}.getOrElse("") case (k, v) if k.endsWith(".boot.class.path") => v
} }.getOrElse("")
val originalBoot = System.getProperty("sun.boot.class.path", findBoot) }
val originalBoot = Option(System.getProperty("sun.boot.class.path")).getOrElse(findBoot)
if (addLibrary) { if (addLibrary) {
val newBootPrefix = if (originalBoot.isEmpty) "" else originalBoot + File.pathSeparator val newBootPrefix = if (originalBoot.isEmpty) "" else originalBoot + File.pathSeparator
newBootPrefix + scalaInstance.libraryJar.getAbsolutePath newBootPrefix + scalaInstance.libraryJar.getAbsolutePath