From e1d60b6de02b311c35c448d2e80e048652416a7a Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 15 Aug 2014 02:57:17 -0400 Subject: [PATCH] Fixes #1484. Fixes another variant of update NPE Ivy gives an array that contains null for caller configurations. sbinary barfs when it sees null. Curiously two of the sbt plugins that hit this bug happens to be from Typesafe: addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.2") addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.7.3") --- ivy/src/main/scala/sbt/IvyRetrieve.scala | 9 ++++++--- ivy/src/main/scala/sbt/UpdateReport.scala | 2 +- .../eviction-warning/build.sbt | 18 ++++++++++++++++++ .../eviction-warning/test | 1 + 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 sbt/src/sbt-test/dependency-management/eviction-warning/build.sbt create mode 100644 sbt/src/sbt-test/dependency-management/eviction-warning/test diff --git a/ivy/src/main/scala/sbt/IvyRetrieve.scala b/ivy/src/main/scala/sbt/IvyRetrieve.scala index ed252e43b..5f07963bd 100644 --- a/ivy/src/main/scala/sbt/IvyRetrieve.scala +++ b/ivy/src/main/scala/sbt/IvyRetrieve.scala @@ -68,11 +68,14 @@ object IvyRetrieve { private[sbt] def moduleRevisionDetail(confReport: ConfigurationResolveReport, dep: IvyNode): ModuleReport = { def toExtraAttributes(ea: ju.Map[_, _]): Map[String, String] = Map(ea.entrySet.toArray collect { - case entry: ju.Map.Entry[_, _] => (entry.getKey.toString, entry.getValue.toString) + case entry: ju.Map.Entry[_, _] if nonEmptyString(entry.getKey.toString).isDefined && nonEmptyString(entry.getValue.toString).isDefined => + (entry.getKey.toString, entry.getValue.toString) }: _*) def toCaller(caller: IvyCaller): Caller = { val m = toModuleID(caller.getModuleRevisionId) - val callerConfigurations = caller.getCallerConfigurations.toArray.toVector + val callerConfigurations = caller.getCallerConfigurations.toArray.toVector collect { + case x if nonEmptyString(x).isDefined => x + } val extraAttributes = toExtraAttributes(caller.getDependencyDescriptor.getExtraAttributes) new Caller(m, callerConfigurations, extraAttributes) } @@ -120,7 +123,7 @@ object IvyRetrieve { val configurations = dep.getConfigurations(confReport.getConfiguration).toArray.toList val licenses: Seq[(String, Option[String])] = mdOpt match { case Some(md) => md.getLicenses.toArray.toVector collect { - case lic: IvyLicense => + case lic: IvyLicense if Option(lic.getName).isDefined => (lic.getName, nonEmptyString(lic.getUrl)) } case _ => Nil diff --git a/ivy/src/main/scala/sbt/UpdateReport.scala b/ivy/src/main/scala/sbt/UpdateReport.scala index d32bbe9a9..7e04d5135 100644 --- a/ivy/src/main/scala/sbt/UpdateReport.scala +++ b/ivy/src/main/scala/sbt/UpdateReport.scala @@ -123,7 +123,7 @@ final class ModuleReport( s"\t\t$module: " + (if (arts.size <= 1) "" else "\n\t\t\t") + arts.mkString("\n\t\t\t") + "\n" } - private[sbt] def detailReport: String = + def detailReport: String = s"\t\t- ${module.revision}\n" + (if (arts.size <= 1) "" else arts.mkString("\t\t\t", "\n\t\t\t", "\n")) + reportStr("status", status) + diff --git a/sbt/src/sbt-test/dependency-management/eviction-warning/build.sbt b/sbt/src/sbt-test/dependency-management/eviction-warning/build.sbt new file mode 100644 index 000000000..e9cd1a4f4 --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/eviction-warning/build.sbt @@ -0,0 +1,18 @@ +lazy val check = taskKey[Unit]("tests update") + +def commonSettings: Seq[Def.Setting[_]] = Seq( + resolvers ++= Resolver.typesafeIvyRepo("releases") :: Resolver.typesafeRepo("releases") :: Resolver.sbtPluginRepo("releases") :: Nil, + check := { + val ur = update.value + import sbinary._, Operations._, DefaultProtocol._ + import Cache.seqFormat, CacheIvy._ + toByteArray(ur) + } + ) + +lazy val projA = project. + settings(commonSettings: _*). + settings( + addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.2"), + addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.7.3") + ) diff --git a/sbt/src/sbt-test/dependency-management/eviction-warning/test b/sbt/src/sbt-test/dependency-management/eviction-warning/test new file mode 100644 index 000000000..8ce9e0e25 --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/eviction-warning/test @@ -0,0 +1 @@ +> projA/check