Nicer ManifestInfo check (#30046)

This commit is contained in:
Ignasi Marimon-Clos 2021-02-22 11:02:06 +01:00 committed by GitHub
parent 6c23c9821c
commit e6c5e32647
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View file

@ -18,6 +18,19 @@ class ManifestInfoSpec extends AkkaSpec {
ManifestInfo.checkSameVersion("Akka", allModules, versions) shouldBe Some(
"You are using version 2.6.4 of Akka, but it appears you (perhaps indirectly) also depend on older versions of related artifacts. " +
"You can solve this by adding an explicit dependency on version 2.6.4 of the [akka-persistence, akka-cluster] artifacts to your project. " +
"Here's a complete collection of detected artifacts: (2.5.3, [akka-cluster, akka-persistence]), (2.6.4, [akka-actor]). " +
"See also: https://doc.akka.io/docs/akka/current/common/binary-compatibility-rules.html#mixed-versioning-is-not-allowed")
}
"support dynver" in {
val versions = Map(
"akka-actor" -> new ManifestInfo.Version("2.6.4"),
"akka-persistence" -> new ManifestInfo.Version("2.6.4+10-abababef"))
val allModules = List("akka-actor", "akka-persistence")
ManifestInfo.checkSameVersion("Akka", allModules, versions) shouldBe Some(
"You are using version 2.6.4+10-abababef of Akka, but it appears you (perhaps indirectly) also depend on older versions of related artifacts. " +
"You can solve this by adding an explicit dependency on version 2.6.4+10-abababef of the [akka-actor] artifacts to your project. " +
"Here's a complete collection of detected artifacts: (2.6.4, [akka-actor]), (2.6.4+10-abababef, [akka-persistence]). " +
"See also: https://doc.akka.io/docs/akka/current/common/binary-compatibility-rules.html#mixed-versioning-is-not-allowed")
}
}

View file

@ -80,11 +80,19 @@ object ManifestInfo extends ExtensionId[ManifestInfo] with ExtensionIdProvider {
if (values.size > 1) {
val highestVersion = values.max
val toBeUpdated = filteredVersions.collect { case (k, v) if v != highestVersion => s"$k" }.mkString(", ")
val groupedByVersion = filteredVersions.toSeq
.groupBy { case (_, v) => v }
.toSeq
.sortBy(_._1)
.map { case (k, v) => k -> v.map(_._1).sorted.mkString("[", ", ", "]") }
.map { case (k, v) => s"($k, $v)" }
.mkString(", ")
Some(
s"You are using version $highestVersion of $productName, but it appears " +
s"you (perhaps indirectly) also depend on older versions of related artifacts. " +
s"You can solve this by adding an explicit dependency on version $highestVersion " +
s"of the [$toBeUpdated] artifacts to your project. " +
s"Here's a complete collection of detected artifacts: ${groupedByVersion}. " +
"See also: https://doc.akka.io/docs/akka/current/common/binary-compatibility-rules.html#mixed-versioning-is-not-allowed")
} else None
}