Skip to content

Commit

Permalink
preserve compiler interface classes across invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
harrah committed Mar 13, 2010
1 parent c18b0e7 commit e1e60fe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions compile/AnalyzingCompiler.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package xsbt
* provided by scalaInstance. This class requires a ComponentManager in order to obtain the interface code to scalac and * 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 * 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.*/ * 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 = 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) apply(sources, classpath, outputDirectory, options, false, callback, maximumErrors, log)
Expand Down Expand Up @@ -52,13 +52,13 @@ class AnalyzingCompiler(val scalaInstance: ScalaInstance, val manager: Component
try { method.invoke(interface, args: _*) } try { method.invoke(interface, args: _*) }
catch { case e: java.lang.reflect.InvocationTargetException => throw e.getCause } 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 interfaceJar = getInterfaceJar(log)
val dual = createDualLoader(scalaInstance.loader, getClass.getClassLoader) // this goes to scalaLoader for scala classes and sbtLoader for xsbti classes 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) new URLClassLoader(Array(interfaceJar.toURI.toURL), dual)
Class.forName(name, true, interfaceLoader)
} }
private def getInterfaceClass(name: String, log: CompileLogger) = Class.forName(name, true, loader)
private def getInterfaceJar(log: CompileLogger) = private def getInterfaceJar(log: CompileLogger) =
{ {
// this is the instance used to compile the interface component // this is the instance used to compile the interface component
Expand Down
2 changes: 1 addition & 1 deletion main/AggressiveCompiler.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AggressiveCompiler extends xsbti.AppMain
val options = Task(args.tail.toSeq) val options = Task(args.tail.toSeq)
val log = new ConsoleLogger with CompileLogger with sbt.IvyLogger { def verbose(msg: => String) = debug(msg) } 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 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) val compileTask = AggressiveCompile(sources, classpath, outputDirectory, options, cacheDirectory, compiler, log)


try { TaskRunner(compileTask.task); true } try { TaskRunner(compileTask.task); true }
Expand Down
2 changes: 2 additions & 0 deletions util/io/Paths.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package xsbt package xsbt


import java.io.File import java.io.File
import java.net.URL


object Paths object Paths
{ {
Expand All @@ -24,6 +25,7 @@ import Paths._
trait PathBase extends NotNull trait PathBase extends NotNull
{ {
def files: Set[File] 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: PathMapper): Iterable[(File,String)] = mapper(files)
def x(mapper: FileMapper): Iterable[(File,File)] = mapper(files) def x(mapper: FileMapper): Iterable[(File,File)] = mapper(files)
def *(filter: java.io.FileFilter): Set[File] = files.flatMap(FileUtilities.listFiles(filter)) def *(filter: java.io.FileFilter): Set[File] = files.flatMap(FileUtilities.listFiles(filter))
Expand Down

0 comments on commit e1e60fe

Please sign in to comment.