From c525fa25516c18a817f8a50ab7a1527d90651f16 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Sat, 31 Aug 2019 12:49:14 -0700 Subject: [PATCH] Use managedFileStampCache for dependency classpath It is redundant and slow to restamp all of the dependency classpath files when they have likely already been stamped by a subproject. For the classfiles of subprojects, we fill the managedFileStampCache with the values returned by the zinc compile analysis product stamps. This is why they are probably already in the managed cache and should be up to date so long as zinc is working correctly. I noticed that various outputFileStamps tasks were showing up in the task timing report when I ran Test / definedTests in the main sbt project. That task became about 400ms faster after this change. --- main/src/main/scala/sbt/Defaults.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index c8062c48f..3205c1a3a 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -2041,7 +2041,12 @@ object Classpaths { excludeFilter in unmanagedJars value ) ).map(exportClasspath) ++ Seq( - sbt.nio.Keys.dependencyClasspathFiles := data(dependencyClasspath.value).map(_.toPath), + dependencyClasspathFiles := data(dependencyClasspath.value).map(_.toPath), + dependencyClasspathFiles / outputFileStamps := { + val cache = managedFileStampCache.value + val stamper = outputFileStamper.value + dependencyClasspathFiles.value.flatMap(p => cache.getOrElseUpdate(p, stamper).map(p -> _)) + } ) private[this] def exportClasspath(s: Setting[Task[Classpath]]): Setting[Task[Classpath]] =