Skip to content

Commit

Permalink
Merge pull request #469 from eed3si9n/wip/bump
Browse files Browse the repository at this point in the history
Convert lastModified() calls to the more precise getModifiedTime()
  • Loading branch information
eed3si9n authored Dec 15, 2017
2 parents 3baf06f + 9784b87 commit 57b6c4d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import java.lang.ref.{ Reference, SoftReference }
import java.io.File
import java.net.URLClassLoader
import java.util.HashMap
import sbt.io.IO

// Hack for testing only
final class ClassLoaderCache(val commonParent: ClassLoader) {
Expand Down Expand Up @@ -43,7 +44,7 @@ final class ClassLoaderCache(val commonParent: ClassLoader) {
mkLoader: () => ClassLoader
): ClassLoader =
synchronized {
val tstamps = files.map(_.lastModified)
val tstamps = files.map(IO.getModifiedTime)
getFromReference(files, tstamps, delegate.get(files), mkLoader)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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 scala.collection.immutable.TreeMap
Expand Down Expand Up @@ -142,7 +142,7 @@ object Stamper {
}

val forHash = (toStamp: File) => tryStamp(Hash.ofFile(toStamp))
val forLastModified = (toStamp: File) => tryStamp(new LastModified(toStamp.lastModified()))
val forLastModified = (toStamp: File) => tryStamp(new LastModified(IO.getModifiedTime(toStamp)))
}

object Stamps {
Expand Down
6 changes: 3 additions & 3 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ object Dependencies {
val scala212 = "2.12.4"
val scala213 = "2.13.0-M2"

private val ioVersion = "1.1.1"
private val utilVersion = "1.1.0"
private val lmVersion = "1.0.4"
private val ioVersion = "1.1.2"
private val utilVersion = "1.1.1"
private val lmVersion = "1.1.1"

private val sbtIO = "org.scala-sbt" %% "io" % ioVersion

Expand Down
2 changes: 2 additions & 0 deletions project/Util.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ object Util {
val timestamp = formatter.format(new Date)
val content = versionLine(version) + "\ntimestamp=" + timestamp
val f = dir / "incrementalcompiler.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)
Expand Down
7 changes: 2 additions & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.3.4")
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.2")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.27")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.1")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0-M1")
addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.12")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "3.0.2")
addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.3.3")
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.0")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.12-rc5")
libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin" % "0.6.0"
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.17")
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import java.nio.file.attribute.{ BasicFileAttributes, FileTime }

import xsbti.compile.FileHash
import sbt.internal.inc.{ EmptyStamp, Stamper }
import sbt.io.IO

object ClasspathCache {
// For more safety, store both the time and size
Expand All @@ -29,7 +30,7 @@ object ClasspathCache {
val attrs = Files.readAttributes(file.toPath, classOf[BasicFileAttributes])
if (attrs.isDirectory) emptyFileHash(file)
else {
val currentMetadata = (attrs.lastModifiedTime(), 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)
Expand Down

0 comments on commit 57b6c4d

Please sign in to comment.