diff --git a/compile/CompilerArguments.scala b/compile/CompilerArguments.scala index 7db74ddc8..b47741cb3 100644 --- a/compile/CompilerArguments.scala +++ b/compile/CompilerArguments.scala @@ -5,7 +5,7 @@ package sbt package compiler import java.io.File - import CompilerArguments.{abs, absString} + import CompilerArguments.{abs, absString, BootClasspathOption} /** Forms the list of options that is passed to the compiler from the required inputs and other options. * The directory containing scala-library.jar and scala-compiler.jar (scalaLibDirectory) is required in @@ -45,11 +45,12 @@ final class CompilerArguments(scalaInstance: ScalaInstance, cp: ClasspathOptions } def filterLibrary(classpath: Seq[File]) = if(cp.filterLibrary) classpath.filterNot(_.getName contains ScalaArtifacts.LibraryID) else classpath - def bootClasspathOption = if(cp.autoBoot) Seq("-bootclasspath", createBootClasspath) else Nil - def bootClasspath = if(cp.autoBoot) sbt.IO.pathSplit(createBootClasspath).map(new File(_)).toSeq else Nil + def bootClasspathOption = if(cp.autoBoot) Seq(BootClasspathOption, createBootClasspath) else Nil + def bootClasspath = if(cp.autoBoot) IO.parseClasspath(createBootClasspath) else Nil } object CompilerArguments { + val BootClasspathOption = "-bootclasspath" def abs(files: Seq[File]): Seq[String] = files.map(_.getAbsolutePath) def abs(files: Set[File]): Seq[String] = abs(files.toSeq) def absString(files: Seq[File]): String = abs(files).mkString(File.pathSeparator) diff --git a/main/actions/AggressiveCompile.scala b/main/actions/AggressiveCompile.scala index 5494518ca..589ad15ed 100644 --- a/main/actions/AggressiveCompile.scala +++ b/main/actions/AggressiveCompile.scala @@ -55,7 +55,7 @@ class AggressiveCompile(cacheDirectory: File) val absClasspath = classpath.map(_.getCanonicalFile) val apiOption= (api: Either[Boolean, Source]) => api.right.toOption val cArgs = new CompilerArguments(compiler.scalaInstance, compiler.cp) - val searchClasspath = withBootclasspath(cArgs, absClasspath) + val searchClasspath = explicitBootClasspath(options.options) ++ withBootclasspath(cArgs, absClasspath) val entry = Locate.entry(searchClasspath, definesClass) val compile0 = (include: Set[File], callback: AnalysisCallback) => { @@ -106,6 +106,9 @@ class AggressiveCompile(cacheDirectory: File) } def javaOnly(f: File) = f.getName.endsWith(".java") + private[this] def explicitBootClasspath(options: Seq[String]): Seq[File] = + options.dropWhile(_ != CompilerArguments.BootClasspathOption).drop(1).take(1).headOption.toList.flatMap(IO.parseClasspath) + import AnalysisFormats._ val store = AggressiveCompile.staticCache(cacheDirectory, AnalysisStore.sync(AnalysisStore.cached(FileBasedStore(cacheDirectory)))) } diff --git a/util/io/IO.scala b/util/io/IO.scala index 651a2d069..91a31f8eb 100644 --- a/util/io/IO.scala +++ b/util/io/IO.scala @@ -627,4 +627,6 @@ object IO } def assertAbsolute(f: File) = assert(f.isAbsolute, "Not absolute: " + f) def assertAbsolute(uri: URI) = assert(uri.isAbsolute, "Not absolute: " + uri) + + def parseClasspath(s: String): Seq[File] = IO.pathSplit(s).map(new File(_)).toSeq }