Include evicted modules and statistics in UpdateReport

This commit is contained in:
Mark Harrah 2011-07-08 21:54:59 -04:00
parent 3c37eaa161
commit 98b60623af
2 changed files with 19 additions and 11 deletions

View File

@ -34,6 +34,9 @@ object IvyRetrieve
}
new ModuleReport(mid, resolved.toSeq, missing.toSeq)
}
def evicted(confReport: ConfigurationResolveReport): Seq[ModuleID] =
confReport.getEvictedNodes.map(node => toModuleID(node.getId))
def toModuleID(revID: ModuleRevisionId): ModuleID =
ModuleID(revID.getOrganisation, revID.getName, revID.getRevision)
@ -45,8 +48,9 @@ object IvyRetrieve
}
def updateReport(report: ResolveReport, cachedDescriptor: File): UpdateReport =
new UpdateReport(cachedDescriptor, reports(report) map configurationReport)
new UpdateReport(cachedDescriptor, reports(report) map configurationReport, updateStats(report))
def updateStats(report: ResolveReport): UpdateStats =
new UpdateStats(report.getResolveTime, report.getDownloadTime, report.getDownloadSize)
def configurationReport(confReport: ConfigurationResolveReport): ConfigurationReport =
new ConfigurationReport(confReport.getConfiguration, moduleReports(confReport))
new ConfigurationReport(confReport.getConfiguration, moduleReports(confReport), evicted(confReport))
}

View File

@ -12,15 +12,15 @@ package sbt
* @param configurations a sequence containing one report for each configuration resolved.
* @see sbt.RichUpdateReport
*/
final class UpdateReport(val cachedDescriptor: File, val configurations: Seq[ConfigurationReport])
final class UpdateReport(val cachedDescriptor: File, val configurations: Seq[ConfigurationReport], val stats: UpdateStats)
{
override def toString = "Update report:\n" + configurations.mkString
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} )
new UpdateReport(cachedDescriptor, configurations map { _ retrieve f}, stats )
/** Gets the report for the given configuration, or `None` if the configuration was not resolved.*/
def configuration(s: String) = configurations.find(_.configuration == s)
@ -33,9 +33,9 @@ final class UpdateReport(val cachedDescriptor: File, val configurations: Seq[Con
* @param configuration the configuration this report is for.
* @param modules a seqeuence containing one report for each module resolved for this configuration.
*/
final class ConfigurationReport(val configuration: String, val modules: Seq[ModuleReport])
final class ConfigurationReport(val configuration: String, val modules: Seq[ModuleReport], val evicted: Seq[ModuleID])
{
override def toString = "\t" + configuration + ":\n" + modules.mkString
override def toString = "\t" + configuration + ":\n" + modules.mkString + evicted.map("\t\t(EVICTED) " + _ + "\n").mkString
/** All resolved modules for this configuration.
* For a given organization and module name, there is only one revision/`ModuleID` in this sequence.
@ -43,7 +43,7 @@ final class ConfigurationReport(val configuration: String, val modules: Seq[Modu
def allModules: Seq[ModuleID] = modules.map(_.module)
def retrieve(f: (String, ModuleID, Artifact, File) => File): ConfigurationReport =
new ConfigurationReport(configuration, modules map { _.retrieve( (mid,art,file) => f(configuration, mid, art, file)) })
new ConfigurationReport(configuration, modules map { _.retrieve( (mid,art,file) => f(configuration, mid, art, file)) }, evicted)
}
/** Provides information about the resolution of a module.
@ -119,9 +119,13 @@ object UpdateReport
val newConfigurations = report.configurations.map { confReport =>
import confReport._
val newModules = modules map { modReport => f(configuration, modReport) }
new ConfigurationReport(configuration, newModules)
new ConfigurationReport(configuration, newModules, evicted)
}
new UpdateReport(report.cachedDescriptor, newConfigurations)
new UpdateReport(report.cachedDescriptor, newConfigurations, report.stats)
}
}
}
final class UpdateStats(val resolveTime: Long, val downloadTime: Long, val downloadSize: Long)
{
override def toString = Seq("Resolve time: " + resolveTime + " ms", "Download time: " + downloadTime + " ms", "Download size: " + downloadSize + " bytes").mkString(", ")
}