mirror of https://github.com/sbt/sbt.git
Add a new eviction warning summary to decide whether or not to warn eviction summary.
This commit is contained in:
parent
0d21ae6369
commit
091edf6ea1
|
|
@ -11,6 +11,7 @@ final class EvictionWarningOptions private[sbt] (
|
|||
val warnScalaVersionEviction: Boolean,
|
||||
val warnDirectEvictions: Boolean,
|
||||
val warnTransitiveEvictions: Boolean,
|
||||
val warnEvictionSummary: Boolean,
|
||||
val infoAllEvictions: Boolean,
|
||||
val showCallers: Boolean,
|
||||
val guessCompatible: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean]
|
||||
|
|
@ -23,6 +24,8 @@ final class EvictionWarningOptions private[sbt] (
|
|||
copy(warnDirectEvictions = warnDirectEvictions)
|
||||
def withWarnTransitiveEvictions(warnTransitiveEvictions: Boolean): EvictionWarningOptions =
|
||||
copy(warnTransitiveEvictions = warnTransitiveEvictions)
|
||||
def withWarnEvictionSummary(warnEvictionSummary: Boolean): EvictionWarningOptions =
|
||||
copy(warnEvictionSummary = warnEvictionSummary)
|
||||
def withInfoAllEvictions(infoAllEvictions: Boolean): EvictionWarningOptions =
|
||||
copy(infoAllEvictions = infoAllEvictions)
|
||||
def withShowCallers(showCallers: Boolean): EvictionWarningOptions =
|
||||
|
|
@ -37,6 +40,7 @@ final class EvictionWarningOptions private[sbt] (
|
|||
warnScalaVersionEviction: Boolean = warnScalaVersionEviction,
|
||||
warnDirectEvictions: Boolean = warnDirectEvictions,
|
||||
warnTransitiveEvictions: Boolean = warnTransitiveEvictions,
|
||||
warnEvictionSummary: Boolean = warnEvictionSummary,
|
||||
infoAllEvictions: Boolean = infoAllEvictions,
|
||||
showCallers: Boolean = showCallers,
|
||||
guessCompatible: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] =
|
||||
|
|
@ -47,6 +51,7 @@ final class EvictionWarningOptions private[sbt] (
|
|||
warnScalaVersionEviction = warnScalaVersionEviction,
|
||||
warnDirectEvictions = warnDirectEvictions,
|
||||
warnTransitiveEvictions = warnTransitiveEvictions,
|
||||
warnEvictionSummary = warnEvictionSummary,
|
||||
infoAllEvictions = infoAllEvictions,
|
||||
showCallers = showCallers,
|
||||
guessCompatible = guessCompatible
|
||||
|
|
@ -55,19 +60,23 @@ final class EvictionWarningOptions private[sbt] (
|
|||
|
||||
object EvictionWarningOptions {
|
||||
def empty: EvictionWarningOptions =
|
||||
new EvictionWarningOptions(Vector(),
|
||||
warnScalaVersionEviction = false,
|
||||
warnDirectEvictions = false,
|
||||
warnTransitiveEvictions = false,
|
||||
infoAllEvictions = false,
|
||||
showCallers = false,
|
||||
defaultGuess)
|
||||
new EvictionWarningOptions(
|
||||
Vector(),
|
||||
warnScalaVersionEviction = false,
|
||||
warnDirectEvictions = false,
|
||||
warnTransitiveEvictions = false,
|
||||
warnEvictionSummary = false,
|
||||
infoAllEvictions = false,
|
||||
showCallers = false,
|
||||
defaultGuess
|
||||
)
|
||||
def default: EvictionWarningOptions =
|
||||
new EvictionWarningOptions(
|
||||
Vector(Compile),
|
||||
warnScalaVersionEviction = true,
|
||||
warnDirectEvictions = true,
|
||||
warnTransitiveEvictions = true,
|
||||
warnEvictionSummary = false,
|
||||
infoAllEvictions = false,
|
||||
showCallers = true,
|
||||
defaultGuess
|
||||
|
|
@ -78,10 +87,22 @@ object EvictionWarningOptions {
|
|||
warnScalaVersionEviction = true,
|
||||
warnDirectEvictions = true,
|
||||
warnTransitiveEvictions = true,
|
||||
warnEvictionSummary = false,
|
||||
infoAllEvictions = true,
|
||||
showCallers = true,
|
||||
defaultGuess
|
||||
)
|
||||
def summary: EvictionWarningOptions =
|
||||
new EvictionWarningOptions(
|
||||
Vector(Compile),
|
||||
warnScalaVersionEviction = false,
|
||||
warnDirectEvictions = false,
|
||||
warnTransitiveEvictions = false,
|
||||
warnEvictionSummary = true,
|
||||
infoAllEvictions = false,
|
||||
showCallers = false,
|
||||
defaultGuess
|
||||
)
|
||||
|
||||
lazy val defaultGuess: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] =
|
||||
guessSbtOne orElse guessSecondSegment orElse guessSemVer orElse guessFalse
|
||||
|
|
@ -303,6 +324,10 @@ object EvictionWarning {
|
|||
implicit val evictionWarningLines: ShowLines[EvictionWarning] = ShowLines { a: EvictionWarning =>
|
||||
import ShowLines._
|
||||
val out: mutable.ListBuffer[String] = mutable.ListBuffer()
|
||||
if (a.options.warnEvictionSummary && a.allEvictions.nonEmpty) {
|
||||
out += "There may be incompatibilities among your library dependencies."
|
||||
}
|
||||
|
||||
if (a.scalaEvictions.nonEmpty) {
|
||||
out += "Scala version was updated by one of library dependencies:"
|
||||
out ++= (a.scalaEvictions flatMap { _.lines })
|
||||
|
|
@ -317,7 +342,7 @@ object EvictionWarning {
|
|||
out ++= (a.transitiveEvictions flatMap { _.lines })
|
||||
}
|
||||
|
||||
if (a.allEvictions.nonEmpty && a.reportedEvictions.nonEmpty) {
|
||||
if (a.allEvictions.nonEmpty && (a.options.warnEvictionSummary || a.reportedEvictions.nonEmpty)) {
|
||||
out += "Run 'evicted' to see detailed eviction warnings"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,16 +12,18 @@ class EvictionWarningSpec extends BaseIvySpecification {
|
|||
it should "not be detected if it's disabled" in scalaVersionWarn2()
|
||||
it should "print out message about the eviction" in scalaVersionWarn3()
|
||||
it should "print out message about the eviction with callers" in scalaVersionWarn4()
|
||||
it should "print out summary about the eviction if warn eviction summary enabled" in scalaVersionWarn5()
|
||||
|
||||
"""Non-eviction of overridden scala-library whose scalaVersion
|
||||
""" should "not be detected if it's enabled" in scalaVersionWarn5()
|
||||
it should "not be detected if it's disabled" in scalaVersionWarn6()
|
||||
""" should "not be detected if it's enabled" in scalaVersionNoWarn1()
|
||||
it should "not be detected if it's disabled" in scalaVersionNoWarn2()
|
||||
|
||||
"""Including two (suspect) binary incompatible Java libraries to direct dependencies
|
||||
""" should "be detected as eviction" in javaLibWarn1()
|
||||
it should "not be detected if it's disabled" in javaLibWarn2()
|
||||
it should "print out message about the eviction" in javaLibWarn3()
|
||||
it should "print out message about the eviction with callers" in javaLibWarn4()
|
||||
it should "print out summary about the eviction if warn eviction summary enabled" in javaLibWarn5()
|
||||
|
||||
"""Including two (suspect) binary compatible Java libraries to direct dependencies
|
||||
""" should "not be detected as eviction" in javaLibNoWarn1()
|
||||
|
|
@ -35,6 +37,7 @@ class EvictionWarningSpec extends BaseIvySpecification {
|
|||
"""Including two (suspect) binary incompatible Scala libraries to direct dependencies
|
||||
""" should "be detected as eviction" in scalaLibWarn1()
|
||||
it should "print out message about the eviction" in scalaLibWarn2()
|
||||
it should "print out summary about the eviction if warn eviction summary enabled" in scalaLibWarn3()
|
||||
|
||||
"""Including two (suspect) binary compatible Scala libraries to direct dependencies
|
||||
""" should "not be detected as eviction" in scalaLibNoWarn1()
|
||||
|
|
@ -43,6 +46,7 @@ class EvictionWarningSpec extends BaseIvySpecification {
|
|||
"""Including two (suspect) transitively binary incompatible Scala libraries to direct dependencies
|
||||
""" should "be detected as eviction" in scalaLibTransitiveWarn2()
|
||||
it should "print out message about the eviction if it's enabled" in scalaLibTransitiveWarn3()
|
||||
it should "print out summary about the eviction if warn eviction summary enabled" in scalaLibTransitiveWarn4()
|
||||
|
||||
"Comparing sbt 0.x" should "use Second Segment Variation semantics" in {
|
||||
val m1 = "org.scala-sbt" % "util-logging" % "0.13.16"
|
||||
|
|
@ -133,12 +137,22 @@ class EvictionWarningSpec extends BaseIvySpecification {
|
|||
}
|
||||
|
||||
def scalaVersionWarn5() = {
|
||||
val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2"), overrideScalaVersion = false)
|
||||
val report = ivyUpdate(m)
|
||||
EvictionWarning(m, EvictionWarningOptions.summary, report).lines shouldBe
|
||||
List(
|
||||
"There may be incompatibilities among your library dependencies.",
|
||||
"Run 'evicted' to see detailed eviction warnings"
|
||||
)
|
||||
}
|
||||
|
||||
def scalaVersionNoWarn1() = {
|
||||
val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2"))
|
||||
val report = ivyUpdate(m)
|
||||
EvictionWarning(m, defaultOptions, report).scalaEvictions should have size (0)
|
||||
}
|
||||
|
||||
def scalaVersionWarn6() = {
|
||||
def scalaVersionNoWarn2() = {
|
||||
val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2"))
|
||||
val report = ivyUpdate(m)
|
||||
EvictionWarning(m, defaultOptions.withWarnScalaVersionEviction(false), report).scalaEvictions should have size (0)
|
||||
|
|
@ -192,6 +206,16 @@ class EvictionWarningSpec extends BaseIvySpecification {
|
|||
)
|
||||
}
|
||||
|
||||
def javaLibWarn5() = {
|
||||
val m = module(defaultModuleId, javaLibDirectDeps, Some("2.10.3"))
|
||||
val report = ivyUpdate(m)
|
||||
EvictionWarning(m, EvictionWarningOptions.summary, report).lines shouldBe
|
||||
List(
|
||||
"There may be incompatibilities among your library dependencies.",
|
||||
"Run 'evicted' to see detailed eviction warnings"
|
||||
)
|
||||
}
|
||||
|
||||
def javaLibNoWarn1() = {
|
||||
val deps = Vector(commonsIo14, commonsIo13)
|
||||
val m = module(defaultModuleId, deps, Some("2.10.3"))
|
||||
|
|
@ -247,6 +271,17 @@ class EvictionWarningSpec extends BaseIvySpecification {
|
|||
)
|
||||
}
|
||||
|
||||
def scalaLibWarn3() = {
|
||||
val deps = Vector(scala2104, akkaActor214, akkaActor234)
|
||||
val m = module(defaultModuleId, deps, Some("2.10.4"))
|
||||
val report = ivyUpdate(m)
|
||||
EvictionWarning(m, EvictionWarningOptions.summary, report).lines shouldBe
|
||||
List(
|
||||
"There may be incompatibilities among your library dependencies.",
|
||||
"Run 'evicted' to see detailed eviction warnings"
|
||||
)
|
||||
}
|
||||
|
||||
def scalaLibNoWarn1() = {
|
||||
val deps = Vector(scala2104, akkaActor230, akkaActor234)
|
||||
val m = module(defaultModuleId, deps, Some("2.10.4"))
|
||||
|
|
@ -285,6 +320,16 @@ class EvictionWarningSpec extends BaseIvySpecification {
|
|||
)
|
||||
}
|
||||
|
||||
def scalaLibTransitiveWarn4() = {
|
||||
val m = module(defaultModuleId, scalaLibTransitiveDeps, Some("2.10.4"))
|
||||
val report = ivyUpdate(m)
|
||||
EvictionWarning(m, EvictionWarningOptions.summary, report).lines shouldBe
|
||||
List(
|
||||
"There may be incompatibilities among your library dependencies.",
|
||||
"Run 'evicted' to see detailed eviction warnings"
|
||||
)
|
||||
}
|
||||
|
||||
def dummyScalaModuleInfo(v: String): ScalaModuleInfo =
|
||||
ScalaModuleInfo(
|
||||
scalaFullVersion = v,
|
||||
|
|
|
|||
Loading…
Reference in New Issue