preserve compiler interface classes across invocations

This commit is contained in:
Mark Harrah 2010-03-13 13:25:08 -05:00
parent c18b0e77ab
commit e1e60fe859
3 changed files with 7 additions and 5 deletions

View File

@ -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 File

@ -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 File

@ -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))