mirror of https://github.com/sbt/sbt.git
Merge pull request #1490 from sbt/wip/1484
Fixes NullPointerException during update. Fixes #1484
This commit is contained in:
commit
03ac266b54
|
|
@ -58,6 +58,13 @@ object IvyRetrieve {
|
||||||
moduleIds map { moduleDetail }
|
moduleIds map { moduleDetail }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private[sbt] def nonEmptyString(s: String): Option[String] =
|
||||||
|
s match {
|
||||||
|
case null => None
|
||||||
|
case x if x.trim == "" => None
|
||||||
|
case x => Some(x.trim)
|
||||||
|
}
|
||||||
|
|
||||||
private[sbt] def moduleRevisionDetail(confReport: ConfigurationResolveReport, dep: IvyNode): ModuleReport = {
|
private[sbt] def moduleRevisionDetail(confReport: ConfigurationResolveReport, dep: IvyNode): ModuleReport = {
|
||||||
def toExtraAttributes(ea: ju.Map[_, _]): Map[String, String] =
|
def toExtraAttributes(ea: ju.Map[_, _]): Map[String, String] =
|
||||||
Map(ea.entrySet.toArray collect {
|
Map(ea.entrySet.toArray collect {
|
||||||
|
|
@ -71,25 +78,29 @@ object IvyRetrieve {
|
||||||
}
|
}
|
||||||
val revId = dep.getResolvedId
|
val revId = dep.getResolvedId
|
||||||
val moduleId = toModuleID(revId)
|
val moduleId = toModuleID(revId)
|
||||||
val branch = Option(revId.getBranch)
|
val branch = nonEmptyString(revId.getBranch)
|
||||||
val (status, publicationDate, resolver, artifactResolver) = dep.isLoaded match {
|
val (status, publicationDate, resolver, artifactResolver) = dep.isLoaded match {
|
||||||
case true =>
|
case true =>
|
||||||
(Option(dep.getDescriptor.getStatus),
|
(nonEmptyString(dep.getDescriptor.getStatus),
|
||||||
Some(new ju.Date(dep.getPublication)),
|
Some(new ju.Date(dep.getPublication)),
|
||||||
Option(dep.getModuleRevision.getResolver.getName),
|
nonEmptyString(dep.getModuleRevision.getResolver.getName),
|
||||||
Option(dep.getModuleRevision.getArtifactResolver.getName))
|
nonEmptyString(dep.getModuleRevision.getArtifactResolver.getName))
|
||||||
case _ => (None, None, None, None)
|
case _ => (None, None, None, None)
|
||||||
}
|
}
|
||||||
val (evicted, evictedData, evictedReason) = dep.isEvicted(confReport.getConfiguration) match {
|
val (evicted, evictedData, evictedReason) = dep.isEvicted(confReport.getConfiguration) match {
|
||||||
case true =>
|
case true =>
|
||||||
val ed = dep.getEvictedData(confReport.getConfiguration)
|
val edOpt = Option(dep.getEvictedData(confReport.getConfiguration))
|
||||||
(true,
|
edOpt match {
|
||||||
Some(Option(ed.getConflictManager) map { _.toString } getOrElse { "transitive" }),
|
case Some(ed) =>
|
||||||
Option(ed.getDetail))
|
(true,
|
||||||
|
nonEmptyString(Option(ed.getConflictManager) map { _.toString } getOrElse { "transitive" }),
|
||||||
|
nonEmptyString(ed.getDetail))
|
||||||
|
case None => (true, None, None)
|
||||||
|
}
|
||||||
case _ => (false, None, None)
|
case _ => (false, None, None)
|
||||||
}
|
}
|
||||||
val problem = dep.hasProblem match {
|
val problem = dep.hasProblem match {
|
||||||
case true => Option(dep.getProblem.getMessage)
|
case true => nonEmptyString(dep.getProblem.getMessage)
|
||||||
case _ => None
|
case _ => None
|
||||||
}
|
}
|
||||||
val mdOpt = for {
|
val mdOpt = for {
|
||||||
|
|
@ -98,7 +109,7 @@ object IvyRetrieve {
|
||||||
} yield md
|
} yield md
|
||||||
val homepage = mdOpt match {
|
val homepage = mdOpt match {
|
||||||
case Some(md) =>
|
case Some(md) =>
|
||||||
Option(md.getHomePage)
|
nonEmptyString(md.getHomePage)
|
||||||
case _ => None
|
case _ => None
|
||||||
}
|
}
|
||||||
val extraAttributes: Map[String, String] = toExtraAttributes(mdOpt match {
|
val extraAttributes: Map[String, String] = toExtraAttributes(mdOpt match {
|
||||||
|
|
@ -110,7 +121,7 @@ object IvyRetrieve {
|
||||||
val licenses: Seq[(String, Option[String])] = mdOpt match {
|
val licenses: Seq[(String, Option[String])] = mdOpt match {
|
||||||
case Some(md) => md.getLicenses.toArray.toVector collect {
|
case Some(md) => md.getLicenses.toArray.toVector collect {
|
||||||
case lic: IvyLicense =>
|
case lic: IvyLicense =>
|
||||||
(lic.getName, Option(lic.getUrl))
|
(lic.getName, nonEmptyString(lic.getUrl))
|
||||||
}
|
}
|
||||||
case _ => Nil
|
case _ => Nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue