mirror of https://github.com/sbt/sbt.git
drop canonicalization of files on classpath and other cleanup. Fixes #723.
This commit is contained in:
parent
6def08e029
commit
77001a4259
|
|
@ -261,7 +261,7 @@ object Incremental
|
|||
dependsOn =>
|
||||
{
|
||||
def inv(reason: String): Boolean = {
|
||||
log.debug("Invalidating " + dependsOn.getCanonicalPath + ": " + reason)
|
||||
log.debug("Invalidating " + dependsOn + ": " + reason)
|
||||
true
|
||||
}
|
||||
def entryModified(className: String, classpathEntry: File): Boolean =
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ object Locate
|
|||
def definesClass(entry: File): String => Boolean =
|
||||
if(entry.isDirectory)
|
||||
directoryDefinesClass(entry)
|
||||
else if(entry.exists && classpath.ClasspathUtilities.isArchive(entry))
|
||||
else if(entry.exists && classpath.ClasspathUtilities.isArchive(entry, contentFallback=true))
|
||||
jarDefinesClass(entry)
|
||||
else
|
||||
const(false)
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class AggressiveCompile(cacheFile: File)
|
|||
{
|
||||
import config._
|
||||
import currentSetup._
|
||||
val absClasspath = classpath.map(_.getCanonicalFile)
|
||||
val absClasspath = classpath.map(_.getAbsoluteFile)
|
||||
val apiOption = (api: Either[Boolean, Source]) => api.right.toOption
|
||||
val cArgs = new CompilerArguments(compiler.scalaInstance, compiler.cp)
|
||||
val searchClasspath = explicitBootClasspath(options.options) ++ withBootclasspath(cArgs, absClasspath)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ word ::= [^ \[\]]+
|
|||
comment ::= '#' \S* nl
|
||||
nl ::= '\r' \'n' | '\n' | '\r' | eof
|
||||
*/
|
||||
final case class Statement(command: String, arguments: List[String], successExpected: Boolean, line: Int) extends NotNull
|
||||
final case class Statement(command: String, arguments: List[String], successExpected: Boolean, line: Int)
|
||||
{
|
||||
def linePrefix = "{line " + line + "} "
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ private object TestScriptParser
|
|||
}
|
||||
|
||||
import TestScriptParser._
|
||||
class TestScriptParser(handlers: Map[Char, StatementHandler]) extends RegexParsers with NotNull
|
||||
class TestScriptParser(handlers: Map[Char, StatementHandler]) extends RegexParsers
|
||||
{
|
||||
require(!handlers.isEmpty)
|
||||
override def skipWhitespace = false
|
||||
|
|
@ -42,7 +42,7 @@ class TestScriptParser(handlers: Map[Char, StatementHandler]) extends RegexParse
|
|||
if(handlers.keys.exists(key => key == '+' || key == '-'))
|
||||
sys.error("Start characters cannot be '+' or '-'")
|
||||
|
||||
def parse(scriptFile: File): List[(StatementHandler, Statement)] = parse(read(scriptFile), Some(scriptFile.getCanonicalPath))
|
||||
def parse(scriptFile: File): List[(StatementHandler, Statement)] = parse(read(scriptFile), Some(scriptFile.getAbsolutePath))
|
||||
def parse(script: String): List[(StatementHandler, Statement)] = parse(script, None)
|
||||
private def parse(script: String, label: Option[String]): List[(StatementHandler, Statement)] =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import Constants._
|
|||
|
||||
private[sbt] object Parser
|
||||
{
|
||||
def apply(file: File): ClassFile = Using.fileInputStream(file)(parse(file.getCanonicalPath)).right.get
|
||||
def apply(file: File): ClassFile = Using.fileInputStream(file)(parse(file.getAbsolutePath)).right.get
|
||||
private def parse(fileName: String)(is: InputStream): Either[String, ClassFile] = Right(parseImpl(fileName, is))
|
||||
private def parseImpl(filename: String, is: InputStream): ClassFile =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,24 +74,19 @@ object ClasspathUtilities
|
|||
private[sbt] def printSource(c: Class[_]) =
|
||||
println(c.getName + " loader=" +c.getClassLoader + " location=" + IO.classLocationFile(c))
|
||||
|
||||
def isArchive(file: File): Boolean = isArchiveName(file.getName)
|
||||
def isArchive(file: File, contentFallback: Boolean = false): Boolean =
|
||||
file.isFile && (isArchiveName(file.getName) || (contentFallback && hasZipContent(file)))
|
||||
|
||||
def isArchiveName(fileName: String) = fileName.endsWith(".jar") || fileName.endsWith(".zip")
|
||||
// Partitions the given classpath into (jars, directories)
|
||||
private[sbt] def separate(paths: Iterable[File]): (Iterable[File], Iterable[File]) = paths.partition(isArchive)
|
||||
// Partitions the given classpath into (jars, directories)
|
||||
private[sbt] def buildSearchPaths(classpath: Iterable[File]): (collection.Set[File], collection.Set[File]) =
|
||||
{
|
||||
val (jars, dirs) = separate(classpath)
|
||||
(linkedSet(jars ++ extraJars), linkedSet(dirs ++ extraDirs))
|
||||
}
|
||||
private[sbt] def onClasspath(classpathJars: collection.Set[File], classpathDirectories: collection.Set[File], file: File): Boolean =
|
||||
{
|
||||
val f = file.getCanonicalFile
|
||||
if(ClasspathUtilities.isArchive(f))
|
||||
classpathJars(f)
|
||||
else
|
||||
classpathDirectories.toList.find(Path.relativize(_, f).isDefined).isDefined
|
||||
}
|
||||
|
||||
def hasZipContent(file: File): Boolean = try {
|
||||
Using.fileInputStream(file) { in =>
|
||||
(in.read() == 0x50) &&
|
||||
(in.read() == 0x4b) &&
|
||||
(in.read() == 0x03) &&
|
||||
(in.read() == 0x04)
|
||||
}
|
||||
} catch { case e: Exception => false }
|
||||
|
||||
/** Returns all entries in 'classpath' that correspond to a compiler plugin.*/
|
||||
private[sbt] def compilerPlugins(classpath: Seq[File]): Iterable[File] =
|
||||
|
|
@ -118,32 +113,4 @@ object ClasspathUtilities
|
|||
}
|
||||
catch { case e: Exception => Nil }
|
||||
}
|
||||
|
||||
private lazy val (extraJars, extraDirs) =
|
||||
{
|
||||
import scala.tools.nsc.GenericRunnerCommand
|
||||
val settings = (new GenericRunnerCommand(Nil, message => sys.error(message))).settings
|
||||
val bootPaths = IO.pathSplit(settings.bootclasspath.value).map(p => new File(p)).toList
|
||||
val (bootJars, bootDirs) = separate(bootPaths)
|
||||
val extJars =
|
||||
{
|
||||
val buffer = new ListBuffer[File]
|
||||
def findJars(dir: File)
|
||||
{
|
||||
buffer ++= dir.listFiles(new SimpleFileFilter(isArchive))
|
||||
for(dir <- dir.listFiles(DirectoryFilter))
|
||||
findJars(dir)
|
||||
}
|
||||
for(path <- IO.pathSplit(settings.extdirs.value); dir = new File(path) if dir.isDirectory)
|
||||
findJars(dir)
|
||||
buffer.readOnly.map(_.getCanonicalFile)
|
||||
}
|
||||
(linkedSet(extJars ++ bootJars), linkedSet(bootDirs))
|
||||
}
|
||||
private def linkedSet[T](s: Iterable[T]): Set[T] =
|
||||
{
|
||||
val set: mutable.Set[T] = JavaConversions.asScalaSet(new java.util.LinkedHashSet[T])
|
||||
set ++= s
|
||||
set
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue