[Fix #287] Eviction warning summary shows only binary incompatible

This commit is contained in:
bigwheel 2019-01-10 21:51:49 +09:00
parent 96a3293c7d
commit c1a93c65b7
2 changed files with 28 additions and 18 deletions

View File

@ -195,7 +195,8 @@ final class EvictionWarning private[sbt] (
val scalaEvictions: Seq[EvictionPair],
val directEvictions: Seq[EvictionPair],
val transitiveEvictions: Seq[EvictionPair],
val allEvictions: Seq[EvictionPair]
val allEvictions: Seq[EvictionPair],
val binaryIncompatibleEvictionExists: Boolean
) {
def reportedEvictions: Seq[EvictionPair] =
scalaEvictions ++ directEvictions ++ transitiveEvictions
@ -279,6 +280,7 @@ object EvictionWarning {
val scalaEvictions: mutable.ListBuffer[EvictionPair] = mutable.ListBuffer()
val directEvictions: mutable.ListBuffer[EvictionPair] = mutable.ListBuffer()
val transitiveEvictions: mutable.ListBuffer[EvictionPair] = mutable.ListBuffer()
var binaryIncompatibleEvictionExists = false
def guessCompatible(p: EvictionPair): Boolean =
p.evicteds forall { r =>
options.guessCompatible(
@ -288,18 +290,23 @@ object EvictionWarning {
pairs foreach {
case p if isScalaArtifact(module, p.organization, p.name) =>
(module.scalaModuleInfo, p.winner) match {
case (Some(s), Some(winner))
if (s.scalaFullVersion != winner.module.revision) && options.warnScalaVersionEviction =>
scalaEvictions += p
case (Some(s), Some(winner)) if (s.scalaFullVersion != winner.module.revision) =>
binaryIncompatibleEvictionExists = true
if (options.warnScalaVersionEviction)
scalaEvictions += p
case _ =>
}
case p if p.includesDirect =>
if (!guessCompatible(p) && options.warnDirectEvictions) {
directEvictions += p
if (!guessCompatible(p)) {
binaryIncompatibleEvictionExists = true
if (options.warnDirectEvictions)
directEvictions += p
}
case p =>
if (!guessCompatible(p) && options.warnTransitiveEvictions) {
transitiveEvictions += p
if (!guessCompatible(p)) {
binaryIncompatibleEvictionExists = true
if (options.warnTransitiveEvictions)
transitiveEvictions += p
}
}
new EvictionWarning(
@ -307,14 +314,15 @@ object EvictionWarning {
scalaEvictions.toList,
directEvictions.toList,
transitiveEvictions.toList,
pairs
pairs,
binaryIncompatibleEvictionExists
)
}
implicit val evictionWarningLines: ShowLines[EvictionWarning] = ShowLines { a: EvictionWarning =>
import ShowLines._
val out: mutable.ListBuffer[String] = mutable.ListBuffer()
if ((a.options.warnEvictionSummary || a.reportedEvictions.nonEmpty) && a.allEvictions.nonEmpty) {
if (a.options.warnEvictionSummary && a.binaryIncompatibleEvictionExists) {
out += "There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings."
}

View File

@ -27,7 +27,7 @@ class EvictionWarningSpec extends BaseIvySpecification {
"""Including two (suspect) binary compatible Java libraries to direct dependencies
""" should "not be detected as eviction" in javaLibNoWarn1()
it should "print out message about the eviction" in javaLibNoWarn2()
it should "not print out message about the eviction" in javaLibNoWarn2()
"""Including two (suspect) transitively binary incompatible Java libraries to direct dependencies
""" should "be detected as eviction" in javaLibTransitiveWarn2()
@ -41,7 +41,8 @@ class EvictionWarningSpec extends BaseIvySpecification {
"""Including two (suspect) binary compatible Scala libraries to direct dependencies
""" should "not be detected as eviction" in scalaLibNoWarn1()
it should "print out message about the eviction" in scalaLibNoWarn2()
it should "not print out message about the eviction" in scalaLibNoWarn2()
it should "not print out summary about the eviction even if warn eviction summary enabled" in scalaLibNoWarn3()
"""Including two (suspect) transitively binary incompatible Scala libraries to direct dependencies
""" should "be detected as eviction" in scalaLibTransitiveWarn2()
@ -111,7 +112,6 @@ class EvictionWarningSpec extends BaseIvySpecification {
val report = ivyUpdate(m)
EvictionWarning(m, fullOptions.withShowCallers(false), report).lines shouldBe
List(
"There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.",
"Scala version was updated by one of library dependencies:",
"\t* org.scala-lang:scala-library:2.10.3 is selected over 2.10.2",
"",
@ -125,7 +125,6 @@ class EvictionWarningSpec extends BaseIvySpecification {
val report = ivyUpdate(m)
EvictionWarning(m, fullOptions, report).lines shouldBe
List(
"There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.",
"Scala version was updated by one of library dependencies:",
"\t* org.scala-lang:scala-library:2.10.3 is selected over 2.10.2",
"\t +- com.typesafe.akka:akka-actor_2.10:2.3.0 (depends on 2.10.3)",
@ -182,7 +181,6 @@ class EvictionWarningSpec extends BaseIvySpecification {
val report = ivyUpdate(m)
EvictionWarning(m, fullOptions, report).lines shouldBe
List(
"There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.",
"Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:",
"",
"\t* commons-io:commons-io:2.4 is selected over 1.4",
@ -196,7 +194,6 @@ class EvictionWarningSpec extends BaseIvySpecification {
val report = ivyUpdate(m)
EvictionWarning(m, fullOptions.withShowCallers(true), report).lines shouldBe
List(
"There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.",
"Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:",
"",
"\t* commons-io:commons-io:2.4 is selected over 1.4",
@ -260,7 +257,6 @@ class EvictionWarningSpec extends BaseIvySpecification {
val report = ivyUpdate(m)
EvictionWarning(m, fullOptions, report).lines shouldBe
List(
"There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.",
"Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:",
"",
"\t* com.typesafe.akka:akka-actor_2.10:2.3.4 is selected over 2.1.4",
@ -293,6 +289,13 @@ class EvictionWarningSpec extends BaseIvySpecification {
EvictionWarning(m, fullOptions, report).lines shouldBe Nil
}
def scalaLibNoWarn3() = {
val deps = Vector(scala2104, akkaActor230, akkaActor234)
val m = module(defaultModuleId, deps, Some("2.10.4"))
val report = ivyUpdate(m)
EvictionWarning(m, EvictionWarningOptions.summary, report).lines shouldBe Nil
}
def scalaLibTransitiveDeps = Vector(scala2104, bananaSesame04, akkaRemote234)
def scalaLibTransitiveWarn2() = {
@ -306,7 +309,6 @@ class EvictionWarningSpec extends BaseIvySpecification {
val report = ivyUpdate(m)
EvictionWarning(m, fullOptions, report).lines shouldBe
List(
"There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.",
"Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:",
"",
"\t* com.typesafe.akka:akka-actor_2.10:2.3.4 is selected over 2.1.4",