mirror of https://github.com/sbt/sbt.git
Do not load classes for dependencies since having URLs is enough.
This commit is contained in:
parent
70f2d56604
commit
cbb1e3daf2
|
|
@ -53,32 +53,28 @@ private[sbt] object Analyze
|
||||||
{
|
{
|
||||||
trapAndLog(log)
|
trapAndLog(log)
|
||||||
{
|
{
|
||||||
val loaded = load(tpe, Some("Problem processing dependencies of source " + source))
|
for (url <- Option(loader.getResource(tpe.replace('.', '/') + ClassExt)); file <- IO.urlAsFile(url))
|
||||||
for(clazz <- loaded; file <- ErrorHandling.convert(IO.classLocationFile(clazz)).right)
|
|
||||||
{
|
{
|
||||||
val name = clazz.getName
|
val name = {
|
||||||
if(file.isDirectory)
|
val lastDot = tpe.lastIndexOf('.')
|
||||||
{
|
if (lastDot < 0) tpe else tpe.substring(lastDot + 1)
|
||||||
val resolved = resolveClassFile(file, tpe)
|
|
||||||
assume(resolved.exists, "Resolved class file " + resolved + " from " + source + " did not exist")
|
|
||||||
if(file == outputDirectory)
|
|
||||||
{
|
|
||||||
productToSource.get(resolved) match
|
|
||||||
{
|
|
||||||
case Some(dependsOn) => analysis.sourceDependency(dependsOn, source)
|
|
||||||
case None => analysis.binaryDependency(resolved, clazz.getName, source)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
analysis.binaryDependency(resolved, name, source)
|
|
||||||
}
|
}
|
||||||
else
|
if(url.getProtocol == "jar")
|
||||||
analysis.binaryDependency(file, name, source)
|
analysis.binaryDependency(file, name, source)
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assume(url.getProtocol == "file")
|
||||||
|
productToSource.get(file) match
|
||||||
|
{
|
||||||
|
case Some(dependsOn) => analysis.sourceDependency(dependsOn, source)
|
||||||
|
case None => analysis.binaryDependency(file, name, source)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
classFiles.flatMap(_.types).foreach(processDependency)
|
classFiles.flatMap(_.types).toSet.foreach(processDependency)
|
||||||
readAPI(source, classFiles.toSeq.flatMap(c => load(c.className, Some("Error reading API from class file") )))
|
readAPI(source, classFiles.toSeq.flatMap(c => load(c.className, Some("Error reading API from class file") )))
|
||||||
analysis.endSource(source)
|
analysis.endSource(source)
|
||||||
}
|
}
|
||||||
|
|
@ -106,7 +102,6 @@ private[sbt] object Analyze
|
||||||
}
|
}
|
||||||
private final val ClassExt = ".class"
|
private final val ClassExt = ".class"
|
||||||
private def trimClassExt(name: String) = if(name.endsWith(ClassExt)) name.substring(0, name.length - ClassExt.length) else name
|
private def trimClassExt(name: String) = if(name.endsWith(ClassExt)) name.substring(0, name.length - ClassExt.length) else name
|
||||||
private def resolveClassFile(file: File, className: String): File = (file /: (className.replace('.','/') + ClassExt).split("/"))(new File(_, _))
|
|
||||||
private def guessSourcePath(sourceNameMap: Map[String, Set[File]], classFile: ClassFile, log: Logger) =
|
private def guessSourcePath(sourceNameMap: Map[String, Set[File]], classFile: ClassFile, log: Logger) =
|
||||||
{
|
{
|
||||||
val classNameParts = classFile.className.split("""\.""")
|
val classNameParts = classFile.className.split("""\.""")
|
||||||
|
|
@ -168,4 +163,4 @@ private[sbt] object Analyze
|
||||||
|
|
||||||
private val mainModifiers = STATIC | PUBLIC
|
private val mainModifiers = STATIC | PUBLIC
|
||||||
private val notMainModifiers = ABSTRACT
|
private val notMainModifiers = ABSTRACT
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue