From f45a07624121d7457dd533fc17ebace2dfd576b9 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Fri, 4 Aug 2017 12:03:11 +0100 Subject: [PATCH] Make sure UpdateReport has a nice toString^2 Fixes sbt/sbt#3357 --- .../sbt/librarymanagement/UpdateReportExtra.scala | 7 ++++++- core/src/test/scala/UpdateReportSpec.scala | 11 ++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala b/core/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala index a97441cfd..12a8fbf69 100644 --- a/core/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala +++ b/core/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala @@ -61,7 +61,7 @@ abstract class ModuleReportExtra { s"\t\t- ${module.revision}\n" + (if (arts.size <= 1) "" else arts.mkString("\t\t\t", "\n\t\t\t", "\n")) + reportStr("status", status) + - reportStr("publicationDate", publicationDate map { _.toString }) + + reportStr("publicationDate", publicationDate map calendarToString) + reportStr("resolver", resolver) + reportStr("artifactResolver", artifactResolver) + reportStr("evicted", Some(evicted.toString)) + @@ -96,6 +96,11 @@ abstract class ModuleReportExtra { s"\t\t\t$key: $x\n" } getOrElse "" + private[this] def calendarToString(c: ju.Calendar): String = { + import sjsonnew._, BasicJsonProtocol._ + implicitly[IsoString[ju.Calendar]] to c + } + def retrieve(f: (ModuleID, Artifact, File) => File): ModuleReport = copy(artifacts = artifacts.map { case (art, file) => (art, f(module, art, file)) }) diff --git a/core/src/test/scala/UpdateReportSpec.scala b/core/src/test/scala/UpdateReportSpec.scala index cc7dfd7fd..12d7e70ca 100644 --- a/core/src/test/scala/UpdateReportSpec.scala +++ b/core/src/test/scala/UpdateReportSpec.scala @@ -12,6 +12,7 @@ class UpdateReportSpec extends FlatSpec with Matchers { | compile: | org:name | - 1.0 + | publicationDate: 1970-01-01T00:00:00Z | evicted: false | |""".stripMargin.drop(1)) @@ -32,10 +33,18 @@ class UpdateReportSpec extends FlatSpec with Matchers { Vector(organizationArtifactReport) ) - lazy val moduleReport = + lazy val moduleReport = ( ModuleReport(ModuleID("org", "name", "1.0"), Vector.empty, Vector.empty) + withPublicationDate Some(epochCalendar) + ) lazy val organizationArtifactReport = OrganizationArtifactReport("org", "name", Vector(moduleReport)) + val epochCalendar: java.util.Calendar = { + val utc = java.util.TimeZone getTimeZone "UTC" + val c = new java.util.GregorianCalendar(utc, java.util.Locale.ENGLISH) + c setTimeInMillis 0L + c + } }