Browse files

preserve compiler interface classes across invocations

  • Loading branch information...
1 parent c18b0e7 commit e1e60fe85917bbb0cbed12ea74c701ce76721a98 @harrah committed Mar 13, 2010
Showing with 7 additions and 5 deletions.
  1. +4 −4 compile/AnalyzingCompiler.scala
  2. +1 −1 main/AggressiveCompiler.scala
  3. +2 −0 util/io/Paths.scala
View
8 compile/AnalyzingCompiler.scala
@@ -9,7 +9,7 @@ package xsbt
* provided by scalaInstance. This class requires a ComponentManager in order to obtain the interface code to scalac and
* the analysis plugin. Because these call Scala code for a different Scala version than the one used for this class, they must
* be compiled for the version of Scala being used.*/
-class AnalyzingCompiler(val scalaInstance: ScalaInstance, val manager: ComponentManager) extends NotNull
+class AnalyzingCompiler(val scalaInstance: ScalaInstance, val manager: ComponentManager, log: CompileLogger) extends NotNull
{
def apply(sources: Set[File], classpath: Set[File], outputDirectory: File, options: Seq[String], callback: AnalysisCallback, maximumErrors: Int, log: CompileLogger): Unit =
apply(sources, classpath, outputDirectory, options, false, callback, maximumErrors, log)
@@ -52,13 +52,13 @@ class AnalyzingCompiler(val scalaInstance: ScalaInstance, val manager: Component
try { method.invoke(interface, args: _*) }
catch { case e: java.lang.reflect.InvocationTargetException => throw e.getCause }
}
- private def getInterfaceClass(name: String, log: CompileLogger) =
+ private[this] def loader =
{
val interfaceJar = getInterfaceJar(log)
val dual = createDualLoader(scalaInstance.loader, getClass.getClassLoader) // this goes to scalaLoader for scala classes and sbtLoader for xsbti classes
- val interfaceLoader = new URLClassLoader(Array(interfaceJar.toURI.toURL), dual)
- Class.forName(name, true, interfaceLoader)
+ new URLClassLoader(Array(interfaceJar.toURI.toURL), dual)
}
+ private def getInterfaceClass(name: String, log: CompileLogger) = Class.forName(name, true, loader)
private def getInterfaceJar(log: CompileLogger) =
{
// this is the instance used to compile the interface component
View
2 main/AggressiveCompiler.scala
@@ -30,7 +30,7 @@ class AggressiveCompiler extends xsbti.AppMain
val options = Task(args.tail.toSeq)
val log = new ConsoleLogger with CompileLogger with sbt.IvyLogger { def verbose(msg: => String) = debug(msg) }
val componentManager = new sbt.ComponentManager(launcher.globalLock, app.components, log)
- val compiler = Task(new AnalyzingCompiler(ScalaInstance(args.head, launcher), componentManager))
+ val compiler = Task(new AnalyzingCompiler(ScalaInstance(args.head, launcher), componentManager, log))
val compileTask = AggressiveCompile(sources, classpath, outputDirectory, options, cacheDirectory, compiler, log)
try { TaskRunner(compileTask.task); true }
View
2 util/io/Paths.scala
@@ -4,6 +4,7 @@
package xsbt
import java.io.File
+import java.net.URL
object Paths
{
@@ -24,6 +25,7 @@ import Paths._
trait PathBase extends NotNull
{
def files: Set[File]
+ def urls: Array[URL] = files.toArray[File].map(_.toURI.toURL)
def x(mapper: PathMapper): Iterable[(File,String)] = mapper(files)
def x(mapper: FileMapper): Iterable[(File,File)] = mapper(files)
def *(filter: java.io.FileFilter): Set[File] = files.flatMap(FileUtilities.listFiles(filter))

0 comments on commit e1e60fe

Please sign in to comment.