mirror of https://github.com/sbt/sbt.git
Convert lastModified() to sbt.io.Milli.getModifiedTime(), more precise
This commit is contained in:
parent
ab2dfc7ec5
commit
699b53262a
|
|
@ -21,6 +21,7 @@ import java.net.URLClassLoader
|
|||
import Eval.{ getModule, getValue, WrapValName }
|
||||
|
||||
import sbt.io.{ DirectoryFilter, FileFilter, GlobFilter, Hash, IO, Path }
|
||||
import sbt.io.Milli.getModifiedTime
|
||||
|
||||
// TODO: provide a way to cleanup backing directory
|
||||
|
||||
|
|
@ -485,7 +486,8 @@ private[sbt] object Eval {
|
|||
def filesModifiedBytes(fs: Array[File]): Array[Byte] =
|
||||
if (fs eq null) filesModifiedBytes(Array[File]()) else seqBytes(fs)(fileModifiedBytes)
|
||||
def fileModifiedBytes(f: File): Array[Byte] =
|
||||
(if (f.isDirectory) filesModifiedBytes(f listFiles classDirFilter) else bytes(f.lastModified)) ++
|
||||
(if (f.isDirectory) filesModifiedBytes(f listFiles classDirFilter)
|
||||
else bytes(getModifiedTime(f))) ++
|
||||
bytes(f.getAbsolutePath)
|
||||
def fileExistsBytes(f: File): Array[Byte] =
|
||||
bytes(f.exists) ++
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import sbt.io.{
|
|||
DirectoryFilter,
|
||||
Hash
|
||||
}, Path._
|
||||
import sbt.io.Milli.getModifiedTime
|
||||
import sbt.librarymanagement.Artifact.{ DocClassifier, SourceClassifier }
|
||||
import sbt.librarymanagement.Configurations.{
|
||||
Compile,
|
||||
|
|
@ -2315,7 +2316,7 @@ object Classpaths {
|
|||
case Some(period) =>
|
||||
val fullUpdateOutput = cacheDirectory / "out"
|
||||
val now = System.currentTimeMillis
|
||||
val diff = now - fullUpdateOutput.lastModified()
|
||||
val diff = now - getModifiedTime(fullUpdateOutput)
|
||||
val elapsedDuration = new FiniteDuration(diff, TimeUnit.MILLISECONDS)
|
||||
fullUpdateOutput.exists() && elapsedDuration > period
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import sbt.internal.librarymanagement._
|
|||
import sbt.librarymanagement._
|
||||
import sbt.librarymanagement.syntax._
|
||||
import sbt.util.{ CacheStore, CacheStoreFactory, Logger, Tracked }
|
||||
import sbt.io.Milli.getModifiedTime
|
||||
|
||||
private[sbt] object LibraryManagement {
|
||||
|
||||
|
|
@ -126,7 +127,7 @@ private[sbt] object LibraryManagement {
|
|||
}
|
||||
|
||||
private[this] def fileUptodate(file: File, stamps: Map[File, Long]): Boolean =
|
||||
stamps.get(file).forall(_ == file.lastModified)
|
||||
stamps.get(file).forall(_ == getModifiedTime(file))
|
||||
|
||||
private[sbt] def transitiveScratch(
|
||||
lm: DependencyResolution,
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ object SiteMap {
|
|||
// generates a string suitable for a sitemap file representing the last modified time of the given File
|
||||
private[this] def lastModifiedString(f: File): String = {
|
||||
val formatter = new java.text.SimpleDateFormat("yyyy-MM-dd")
|
||||
// TODO: replace lastModified() with sbt.io.Milli.getModifiedTime(), once the build
|
||||
// has been upgraded to a version of sbt that includes sbt.io.Milli.
|
||||
formatter.format(new java.util.Date(f.lastModified))
|
||||
}
|
||||
// writes the provided XML node to `output` and then gzips it to `gzipped` if `gzip` is true
|
||||
|
|
|
|||
|
|
@ -105,6 +105,8 @@ object Util {
|
|||
val timestamp = formatter.format(new Date)
|
||||
val content = versionLine(version) + "\ntimestamp=" + timestamp
|
||||
val f = dir / "xsbt.version.properties"
|
||||
// TODO: replace lastModified() with sbt.io.Milli.getModifiedTime(), once the build
|
||||
// has been upgraded to a version of sbt that includes sbt.io.Milli.
|
||||
if (!f.exists || f.lastModified < lastCompilationTime(analysis) || !containsVersion(f, version)) {
|
||||
s.log.info("Writing version information to " + f + " :\n" + content)
|
||||
IO.write(f, content)
|
||||
|
|
|
|||
Loading…
Reference in New Issue