From 9a0b59b5979993f7770a6cdb33bd96ecd2ad9d68 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Wed, 29 Aug 2012 11:13:48 -0400 Subject: [PATCH] Force update on change to last modified time of artifacts or cached descriptor. This is part 2 of the fix for #532. It may also fix issues when working with multiple local projects via 'publish-local' and binary dependencies. --- ivy/IvyRetrieve.scala | 2 +- ivy/ResolutionCache.scala | 2 +- ivy/UpdateReport.scala | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ivy/IvyRetrieve.scala b/ivy/IvyRetrieve.scala index cd619afaf..dd0ffe910 100644 --- a/ivy/IvyRetrieve.scala +++ b/ivy/IvyRetrieve.scala @@ -48,7 +48,7 @@ object IvyRetrieve } def updateReport(report: ResolveReport, cachedDescriptor: File): UpdateReport = - new UpdateReport(cachedDescriptor, reports(report) map configurationReport, updateStats(report)) + new UpdateReport(cachedDescriptor, reports(report) map configurationReport, updateStats(report), Map.empty) recomputeStamps() def updateStats(report: ResolveReport): UpdateStats = new UpdateStats(report.getResolveTime, report.getDownloadTime, report.getDownloadSize, false) def configurationReport(confReport: ConfigurationResolveReport): ConfigurationReport = diff --git a/ivy/ResolutionCache.scala b/ivy/ResolutionCache.scala index c8846e251..a5026882b 100644 --- a/ivy/ResolutionCache.scala +++ b/ivy/ResolutionCache.scala @@ -54,7 +54,7 @@ private[sbt] object ResolutionCache private val ReportFileName = "report.xml" // base name (name except for extension) of resolution report file - private val ResolvedName = "resolved" + private val ResolvedName = "resolved.xml" // Cache name private val Name = "sbt-resolution-cache" diff --git a/ivy/UpdateReport.scala b/ivy/UpdateReport.scala index 6f8485c9d..071643eb2 100644 --- a/ivy/UpdateReport.scala +++ b/ivy/UpdateReport.scala @@ -13,15 +13,19 @@ package sbt * @param stats information about the update that produced this report * @see sbt.RichUpdateReport */ -final class UpdateReport(val cachedDescriptor: File, val configurations: Seq[ConfigurationReport], val stats: UpdateStats) +final class UpdateReport(val cachedDescriptor: File, val configurations: Seq[ConfigurationReport], val stats: UpdateStats, private[sbt] val stamps: Map[File,Long]) { + @deprecated("Use the variant that provides timestamps of files.", "0.13.0") + def this(cachedDescriptor: File, configurations: Seq[ConfigurationReport], stats: UpdateStats) = + this(cachedDescriptor, configurations, stats, Map.empty) + override def toString = "Update report:\n\t" + stats + "\n" + configurations.mkString /** All resolved modules in all configurations. */ def allModules: Seq[ModuleID] = configurations.flatMap(_.allModules).distinct def retrieve(f: (String, ModuleID, Artifact, File) => File): UpdateReport = - new UpdateReport(cachedDescriptor, configurations map { _ retrieve f}, stats ) + new UpdateReport(cachedDescriptor, configurations map { _ retrieve f}, stats, stamps ) /** Gets the report for the given configuration, or `None` if the configuration was not resolved.*/ def configuration(s: String) = configurations.find(_.configuration == s) @@ -71,6 +75,13 @@ object UpdateReport /** Provides extra methods for filtering the contents of an `UpdateReport` and for obtaining references to a selected subset of the underlying files. */ final class RichUpdateReport(report: UpdateReport) { + def recomputeStamps(): UpdateReport = + { + val files = report.cachedDescriptor +: allFiles + val stamps = files.map(f => (f, f.lastModified)).toMap + new UpdateReport(report.cachedDescriptor, report.configurations, report.stats, stamps) + } + import DependencyFilter._ /** Obtains all successfully retrieved files in all configurations and modules. */ def allFiles: Seq[File] = matching(DependencyFilter.allPass) @@ -123,7 +134,7 @@ object UpdateReport val newModules = modules map { modReport => f(configuration, modReport) } new ConfigurationReport(configuration, newModules, evicted) } - new UpdateReport(report.cachedDescriptor, newConfigurations, report.stats) + new UpdateReport(report.cachedDescriptor, newConfigurations, report.stats, report.stamps) } } }