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.
This commit is contained in:
Ethan Atkins 2019-08-31 12:49:14 -07:00
parent a7dd86939f
commit c525fa2551
1 changed files with 6 additions and 1 deletions

View File

@ -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]] =