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")
This commit is contained in:
Eugene Yokota 2014-08-15 02:57:17 -04:00
parent 074fbdb9e6
commit e1d60b6de0
4 changed files with 26 additions and 4 deletions

View File

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

View File

@ -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) +

View File

@ -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")
)

View File

@ -0,0 +1 @@
> projA/check