mirror of https://github.com/sbt/sbt.git
Compatible with latest 2.8 nightly
This commit is contained in:
parent
e559ca113f
commit
871b9bbcc2
|
|
@ -47,7 +47,7 @@ class ComponentCompiler(compiler: RawCompiler, manager: ComponentManager)
|
||||||
val start = System.currentTimeMillis
|
val start = System.currentTimeMillis
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
compiler(Set() ++ sourceFiles, Set() ++ xsbtiJars, outputDirectory, Nil, true)
|
compiler(Set() ++ sourceFiles, Set() ++ xsbtiJars, outputDirectory, "-nowarn" :: Nil, true)
|
||||||
manager.log.info(" Compilation completed in " + (System.currentTimeMillis - start) / 1000.0 + " s")
|
manager.log.info(" Compilation completed in " + (System.currentTimeMillis - start) / 1000.0 + " s")
|
||||||
}
|
}
|
||||||
catch { case e: xsbti.CompileFailed => throw new CompileFailed(e.arguments, "Error compiling sbt component '" + id + "'") }
|
catch { case e: xsbti.CompileFailed => throw new CompileFailed(e.arguments, "Error compiling sbt component '" + id + "'") }
|
||||||
|
|
|
||||||
|
|
@ -115,19 +115,18 @@ final class Analyzer(val global: Global, val callback: AnalysisCallback) extends
|
||||||
{
|
{
|
||||||
import scala.tools.nsc.symtab.Flags
|
import scala.tools.nsc.symtab.Flags
|
||||||
val name = sym.fullNameString(File.separatorChar) + (if (sym.hasFlag(Flags.MODULE)) "$" else "")
|
val name = sym.fullNameString(File.separatorChar) + (if (sym.hasFlag(Flags.MODULE)) "$" else "")
|
||||||
val entry = classPath.root.find(name, false)
|
finder.findClass(name) orElse {
|
||||||
if (entry ne null)
|
if(isTopLevelModule(sym))
|
||||||
Some(entry.classFile)
|
{
|
||||||
else if(isTopLevelModule(sym))
|
val linked = sym.linkedClassOfModule
|
||||||
{
|
if(linked == NoSymbol)
|
||||||
val linked = sym.linkedClassOfModule
|
None
|
||||||
if(linked == NoSymbol)
|
else
|
||||||
None
|
classFile(linked)
|
||||||
|
}
|
||||||
else
|
else
|
||||||
classFile(linked)
|
None
|
||||||
}
|
}
|
||||||
else
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private def isTopLevelModule(sym: Symbol): Boolean =
|
private def isTopLevelModule(sym: Symbol): Boolean =
|
||||||
|
|
@ -178,4 +177,37 @@ final class Analyzer(val global: Global, val callback: AnalysisCallback) extends
|
||||||
private def isStringArray(tpe: Type): Boolean = tpe =:= StringArrayType
|
private def isStringArray(tpe: Type): Boolean = tpe =:= StringArrayType
|
||||||
private def isStringArray(sym: Symbol): Boolean = isStringArray(sym.tpe)
|
private def isStringArray(sym: Symbol): Boolean = isStringArray(sym.tpe)
|
||||||
private def isUnitType(tpe: Type) = tpe.typeSymbol == definitions.UnitClass
|
private def isUnitType(tpe: Type) = tpe.typeSymbol == definitions.UnitClass
|
||||||
|
|
||||||
|
// required because the 2.8 way to find a class is:
|
||||||
|
// classPath.findClass(name).flatMap(_.binary)
|
||||||
|
// and the 2.7 way is:
|
||||||
|
// val entry = classPath.root.find(name, false)
|
||||||
|
// if(entry eq null) None else Some(entry.classFile)
|
||||||
|
private lazy val finder = try { new LegacyFinder } catch { case _ => new NewFinder }
|
||||||
|
private trait ClassFinder
|
||||||
|
{
|
||||||
|
def findClass(name: String): Option[AbstractFile]
|
||||||
|
}
|
||||||
|
private class NewFinder extends ClassFinder
|
||||||
|
{
|
||||||
|
def findClass(name: String): Option[AbstractFile] =
|
||||||
|
call[Option[AnyRef]](classPath, "findClass", classOf[String])(name).flatMap(extractClass)
|
||||||
|
private def extractClass(a: AnyRef) =
|
||||||
|
call[Option[AbstractFile]](a, "binary")()
|
||||||
|
}
|
||||||
|
private class LegacyFinder extends ClassFinder
|
||||||
|
{
|
||||||
|
private val root = call[AnyRef](classPath, "root")()
|
||||||
|
def findClass(name: String): Option[AbstractFile] =
|
||||||
|
{
|
||||||
|
val entry = call[Option[AnyRef]](root, "find", classOf[String], classOf[Boolean])(name, boolean2Boolean(false))
|
||||||
|
if (entry eq null)
|
||||||
|
None
|
||||||
|
else
|
||||||
|
Some( call[AbstractFile](entry, "classFile")() )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
import scala.reflect.Manifest
|
||||||
|
private def call[T <: AnyRef](on: AnyRef, name: String, tpes: Class[_]*)(args: AnyRef*)(implicit mf: Manifest[T]): T =
|
||||||
|
mf.erasure.cast(on.getClass.getMethod(name, tpes : _*).invoke(on, args : _*)).asInstanceOf[T]
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#Project properties
|
#Project properties
|
||||||
#Mon Oct 19 11:03:16 EDT 2009
|
#Sat Oct 31 19:01:55 EDT 2009
|
||||||
project.organization=org.scala-tools.sbt
|
project.organization=org.scala-tools.sbt
|
||||||
project.name=xsbt
|
project.name=xsbt
|
||||||
sbt.version=0.5.6-p2
|
sbt.version=0.5.6-p2
|
||||||
project.version=0.6.0
|
project.version=0.6.1
|
||||||
scala.version=2.7.5
|
scala.version=2.7.5
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue