mirror of https://github.com/sbt/sbt.git
Use time wrapped stamper for dependency classpath
It is expensive to compute the the hash of every jar on the classpath so we can try to avoid that by using the timeWrappedStamper which only computes the hash if the last modified time has changed.
This commit is contained in:
parent
c9dc041643
commit
7ba5fd79f8
|
|
@ -74,6 +74,7 @@ import sbt.librarymanagement.CrossVersion.{ binarySbtVersion, binaryScalaVersion
|
|||
import sbt.librarymanagement._
|
||||
import sbt.librarymanagement.ivy._
|
||||
import sbt.librarymanagement.syntax._
|
||||
import sbt.nio.FileStamp
|
||||
import sbt.nio.Keys._
|
||||
import sbt.nio.file.syntax._
|
||||
import sbt.nio.file.{ FileTreeView, Glob, RecursiveGlob }
|
||||
|
|
@ -2215,9 +2216,11 @@ object Classpaths {
|
|||
).map(exportClasspath) ++ Seq(
|
||||
dependencyClasspathFiles := data(dependencyClasspath.value).map(_.toPath),
|
||||
dependencyClasspathFiles / outputFileStamps := {
|
||||
val cache = managedFileStampCache.value
|
||||
val stamper = (managedSourcePaths / outputFileStamper).value
|
||||
dependencyClasspathFiles.value.flatMap(p => cache.getOrElseUpdate(p, stamper).map(p -> _))
|
||||
val stamper = timeWrappedStamper.value
|
||||
val converter = fileConverter.value
|
||||
dependencyClasspathFiles.value.flatMap(
|
||||
p => FileStamp(stamper.library(converter.toVirtualFile(p))).map(p -> _)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import java.io.{ File, IOException }
|
|||
import java.nio.file.{ Path, Paths }
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
import sbt.internal.inc.{ EmptyStamp, Stamper, LastModified => IncLastModified }
|
||||
import sbt.internal.inc.{ EmptyStamp, Stamper, Hash => IncHash, LastModified => IncLastModified }
|
||||
import sbt.io.IO
|
||||
import sbt.nio.file.FileAttributes
|
||||
import sjsonnew.{ Builder, JsonFormat, Unbuilder, deserializationError }
|
||||
|
|
@ -65,6 +65,11 @@ object FileStamp {
|
|||
case FileStamper.Hash => hash(path)
|
||||
case FileStamper.LastModified => lastModified(path)
|
||||
}
|
||||
private[sbt] def apply(stamp: XStamp): Option[FileStamp] = stamp match {
|
||||
case lm: IncLastModified => Some(new LastModified(lm.value))
|
||||
case s: IncHash => Some(fromZincStamp(s))
|
||||
case _ => None
|
||||
}
|
||||
private[sbt] def apply(path: Path, fileAttributes: FileAttributes): Option[FileStamp] =
|
||||
try {
|
||||
if (fileAttributes.isDirectory) lastModified(path)
|
||||
|
|
|
|||
Loading…
Reference in New Issue