From 6cebf6e126310907fd7d8b4176735ab46b686c21 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Wed, 13 Dec 2017 16:11:45 +0000 Subject: [PATCH] Use IO.getModified over importing the method --- .../scala/sbt/internal/inc/classpath/ClassLoaderCache.scala | 4 ++-- .../zinc-core/src/main/scala/sbt/internal/inc/Stamp.scala | 5 ++--- .../main/scala/sbt/internal/inc/caching/ClasspathCache.scala | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClassLoaderCache.scala b/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClassLoaderCache.scala index 65f4367f80..3bc90222be 100644 --- a/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClassLoaderCache.scala +++ b/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClassLoaderCache.scala @@ -14,7 +14,7 @@ import java.lang.ref.{ Reference, SoftReference } import java.io.File import java.net.URLClassLoader import java.util.HashMap -import sbt.io.IO.getModifiedTime +import sbt.io.IO // Hack for testing only final class ClassLoaderCache(val commonParent: ClassLoader) { @@ -44,7 +44,7 @@ final class ClassLoaderCache(val commonParent: ClassLoader) { mkLoader: () => ClassLoader ): ClassLoader = synchronized { - val tstamps = files.map(getModifiedTime) + val tstamps = files.map(IO.getModifiedTime) getFromReference(files, tstamps, delegate.get(files), mkLoader) } diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/Stamp.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/Stamp.scala index cf1bef778b..ff518ad283 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/Stamp.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/Stamp.scala @@ -13,9 +13,8 @@ import java.io.{ File, IOException } import java.util import java.util.Optional -import sbt.io.{ Hash => IOHash } +import sbt.io.{ Hash => IOHash, IO } import xsbti.compile.analysis.{ ReadStamps, Stamp } -import sbt.io.IO.getModifiedTime import scala.collection.immutable.TreeMap import scala.util.matching.Regex @@ -143,7 +142,7 @@ object Stamper { } val forHash = (toStamp: File) => tryStamp(Hash.ofFile(toStamp)) - val forLastModified = (toStamp: File) => tryStamp(new LastModified(getModifiedTime(toStamp))) + val forLastModified = (toStamp: File) => tryStamp(new LastModified(IO.getModifiedTime(toStamp))) } object Stamps { diff --git a/zinc/src/main/scala/sbt/internal/inc/caching/ClasspathCache.scala b/zinc/src/main/scala/sbt/internal/inc/caching/ClasspathCache.scala index ef3ceef513..c715d79bd3 100644 --- a/zinc/src/main/scala/sbt/internal/inc/caching/ClasspathCache.scala +++ b/zinc/src/main/scala/sbt/internal/inc/caching/ClasspathCache.scala @@ -7,7 +7,7 @@ import java.nio.file.attribute.{ BasicFileAttributes, FileTime } import xsbti.compile.FileHash import sbt.internal.inc.{ EmptyStamp, Stamper } -import sbt.io.IO.getModifiedTime +import sbt.io.IO object ClasspathCache { // For more safety, store both the time and size @@ -30,7 +30,7 @@ object ClasspathCache { val attrs = Files.readAttributes(file.toPath, classOf[BasicFileAttributes]) if (attrs.isDirectory) emptyFileHash(file) else { - val currentMetadata = (FileTime.fromMillis(getModifiedTime(file)), attrs.size()) + val currentMetadata = (FileTime.fromMillis(IO.getModifiedTime(file)), attrs.size()) Option(cacheMetadataJar.get(file)) match { case Some((metadata, hashHit)) if metadata == currentMetadata => hashHit case _ => genFileHash(file, currentMetadata)