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 warnScalaVersionEviction: Boolean,
|
||||||
val warnDirectEvictions: Boolean,
|
val warnDirectEvictions: Boolean,
|
||||||
val warnTransitiveEvictions: Boolean,
|
val warnTransitiveEvictions: Boolean,
|
||||||
|
val warnEvictionSummary: Boolean,
|
||||||
val infoAllEvictions: Boolean,
|
val infoAllEvictions: Boolean,
|
||||||
val showCallers: Boolean,
|
val showCallers: Boolean,
|
||||||
val guessCompatible: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean]
|
val guessCompatible: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean]
|
||||||
|
|
@ -23,6 +24,8 @@ final class EvictionWarningOptions private[sbt] (
|
||||||
copy(warnDirectEvictions = warnDirectEvictions)
|
copy(warnDirectEvictions = warnDirectEvictions)
|
||||||
def withWarnTransitiveEvictions(warnTransitiveEvictions: Boolean): EvictionWarningOptions =
|
def withWarnTransitiveEvictions(warnTransitiveEvictions: Boolean): EvictionWarningOptions =
|
||||||
copy(warnTransitiveEvictions = warnTransitiveEvictions)
|
copy(warnTransitiveEvictions = warnTransitiveEvictions)
|
||||||
|
def withWarnEvictionSummary(warnEvictionSummary: Boolean): EvictionWarningOptions =
|
||||||
|
copy(warnEvictionSummary = warnEvictionSummary)
|
||||||
def withInfoAllEvictions(infoAllEvictions: Boolean): EvictionWarningOptions =
|
def withInfoAllEvictions(infoAllEvictions: Boolean): EvictionWarningOptions =
|
||||||
copy(infoAllEvictions = infoAllEvictions)
|
copy(infoAllEvictions = infoAllEvictions)
|
||||||
def withShowCallers(showCallers: Boolean): EvictionWarningOptions =
|
def withShowCallers(showCallers: Boolean): EvictionWarningOptions =
|
||||||
|
|
@ -37,6 +40,7 @@ final class EvictionWarningOptions private[sbt] (
|
||||||
warnScalaVersionEviction: Boolean = warnScalaVersionEviction,
|
warnScalaVersionEviction: Boolean = warnScalaVersionEviction,
|
||||||
warnDirectEvictions: Boolean = warnDirectEvictions,
|
warnDirectEvictions: Boolean = warnDirectEvictions,
|
||||||
warnTransitiveEvictions: Boolean = warnTransitiveEvictions,
|
warnTransitiveEvictions: Boolean = warnTransitiveEvictions,
|
||||||
|
warnEvictionSummary: Boolean = warnEvictionSummary,
|
||||||
infoAllEvictions: Boolean = infoAllEvictions,
|
infoAllEvictions: Boolean = infoAllEvictions,
|
||||||
showCallers: Boolean = showCallers,
|
showCallers: Boolean = showCallers,
|
||||||
guessCompatible: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] =
|
guessCompatible: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] =
|
||||||
|
|
@ -47,6 +51,7 @@ final class EvictionWarningOptions private[sbt] (
|
||||||
warnScalaVersionEviction = warnScalaVersionEviction,
|
warnScalaVersionEviction = warnScalaVersionEviction,
|
||||||
warnDirectEvictions = warnDirectEvictions,
|
warnDirectEvictions = warnDirectEvictions,
|
||||||
warnTransitiveEvictions = warnTransitiveEvictions,
|
warnTransitiveEvictions = warnTransitiveEvictions,
|
||||||
|
warnEvictionSummary = warnEvictionSummary,
|
||||||
infoAllEvictions = infoAllEvictions,
|
infoAllEvictions = infoAllEvictions,
|
||||||
showCallers = showCallers,
|
showCallers = showCallers,
|
||||||
guessCompatible = guessCompatible
|
guessCompatible = guessCompatible
|
||||||
|
|
@ -55,19 +60,23 @@ final class EvictionWarningOptions private[sbt] (
|
||||||
|
|
||||||
object EvictionWarningOptions {
|
object EvictionWarningOptions {
|
||||||
def empty: EvictionWarningOptions =
|
def empty: EvictionWarningOptions =
|
||||||
new EvictionWarningOptions(Vector(),
|
new EvictionWarningOptions(
|
||||||
warnScalaVersionEviction = false,
|
Vector(),
|
||||||
warnDirectEvictions = false,
|
warnScalaVersionEviction = false,
|
||||||
warnTransitiveEvictions = false,
|
warnDirectEvictions = false,
|
||||||
infoAllEvictions = false,
|
warnTransitiveEvictions = false,
|
||||||
showCallers = false,
|
warnEvictionSummary = false,
|
||||||
defaultGuess)
|
infoAllEvictions = false,
|
||||||
|
showCallers = false,
|
||||||
|
defaultGuess
|
||||||
|
)
|
||||||
def default: EvictionWarningOptions =
|
def default: EvictionWarningOptions =
|
||||||
new EvictionWarningOptions(
|
new EvictionWarningOptions(
|
||||||
Vector(Compile),
|
Vector(Compile),
|
||||||
warnScalaVersionEviction = true,
|
warnScalaVersionEviction = true,
|
||||||
warnDirectEvictions = true,
|
warnDirectEvictions = true,
|
||||||
warnTransitiveEvictions = true,
|
warnTransitiveEvictions = true,
|
||||||
|
warnEvictionSummary = false,
|
||||||
infoAllEvictions = false,
|
infoAllEvictions = false,
|
||||||
showCallers = true,
|
showCallers = true,
|
||||||
defaultGuess
|
defaultGuess
|
||||||
|
|
@ -78,10 +87,22 @@ object EvictionWarningOptions {
|
||||||
warnScalaVersionEviction = true,
|
warnScalaVersionEviction = true,
|
||||||
warnDirectEvictions = true,
|
warnDirectEvictions = true,
|
||||||
warnTransitiveEvictions = true,
|
warnTransitiveEvictions = true,
|
||||||
|
warnEvictionSummary = false,
|
||||||
infoAllEvictions = true,
|
infoAllEvictions = true,
|
||||||
showCallers = true,
|
showCallers = true,
|
||||||
defaultGuess
|
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] =
|
lazy val defaultGuess: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] =
|
||||||
guessSbtOne orElse guessSecondSegment orElse guessSemVer orElse guessFalse
|
guessSbtOne orElse guessSecondSegment orElse guessSemVer orElse guessFalse
|
||||||
|
|
@ -303,6 +324,10 @@ object EvictionWarning {
|
||||||
implicit val evictionWarningLines: ShowLines[EvictionWarning] = ShowLines { a: EvictionWarning =>
|
implicit val evictionWarningLines: ShowLines[EvictionWarning] = ShowLines { a: EvictionWarning =>
|
||||||
import ShowLines._
|
import ShowLines._
|
||||||
val out: mutable.ListBuffer[String] = mutable.ListBuffer()
|
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) {
|
if (a.scalaEvictions.nonEmpty) {
|
||||||
out += "Scala version was updated by one of library dependencies:"
|
out += "Scala version was updated by one of library dependencies:"
|
||||||
out ++= (a.scalaEvictions flatMap { _.lines })
|
out ++= (a.scalaEvictions flatMap { _.lines })
|
||||||
|
|
@ -317,7 +342,7 @@ object EvictionWarning {
|
||||||
out ++= (a.transitiveEvictions flatMap { _.lines })
|
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"
|
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 "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" in scalaVersionWarn3()
|
||||||
it should "print out message about the eviction with callers" in scalaVersionWarn4()
|
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
|
"""Non-eviction of overridden scala-library whose scalaVersion
|
||||||
""" should "not be detected if it's enabled" in scalaVersionWarn5()
|
""" should "not be detected if it's enabled" in scalaVersionNoWarn1()
|
||||||
it should "not be detected if it's disabled" in scalaVersionWarn6()
|
it should "not be detected if it's disabled" in scalaVersionNoWarn2()
|
||||||
|
|
||||||
"""Including two (suspect) binary incompatible Java libraries to direct dependencies
|
"""Including two (suspect) binary incompatible Java libraries to direct dependencies
|
||||||
""" should "be detected as eviction" in javaLibWarn1()
|
""" should "be detected as eviction" in javaLibWarn1()
|
||||||
it should "not be detected if it's disabled" in javaLibWarn2()
|
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" in javaLibWarn3()
|
||||||
it should "print out message about the eviction with callers" in javaLibWarn4()
|
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
|
"""Including two (suspect) binary compatible Java libraries to direct dependencies
|
||||||
""" should "not be detected as eviction" in javaLibNoWarn1()
|
""" 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
|
"""Including two (suspect) binary incompatible Scala libraries to direct dependencies
|
||||||
""" should "be detected as eviction" in scalaLibWarn1()
|
""" should "be detected as eviction" in scalaLibWarn1()
|
||||||
it should "print out message about the eviction" in scalaLibWarn2()
|
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
|
"""Including two (suspect) binary compatible Scala libraries to direct dependencies
|
||||||
""" should "not be detected as eviction" in scalaLibNoWarn1()
|
""" 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
|
"""Including two (suspect) transitively binary incompatible Scala libraries to direct dependencies
|
||||||
""" should "be detected as eviction" in scalaLibTransitiveWarn2()
|
""" 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 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 {
|
"Comparing sbt 0.x" should "use Second Segment Variation semantics" in {
|
||||||
val m1 = "org.scala-sbt" % "util-logging" % "0.13.16"
|
val m1 = "org.scala-sbt" % "util-logging" % "0.13.16"
|
||||||
|
|
@ -133,12 +137,22 @@ class EvictionWarningSpec extends BaseIvySpecification {
|
||||||
}
|
}
|
||||||
|
|
||||||
def scalaVersionWarn5() = {
|
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 m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2"))
|
||||||
val report = ivyUpdate(m)
|
val report = ivyUpdate(m)
|
||||||
EvictionWarning(m, defaultOptions, report).scalaEvictions should have size (0)
|
EvictionWarning(m, defaultOptions, report).scalaEvictions should have size (0)
|
||||||
}
|
}
|
||||||
|
|
||||||
def scalaVersionWarn6() = {
|
def scalaVersionNoWarn2() = {
|
||||||
val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2"))
|
val m = module(defaultModuleId, scalaVersionDeps, Some("2.10.2"))
|
||||||
val report = ivyUpdate(m)
|
val report = ivyUpdate(m)
|
||||||
EvictionWarning(m, defaultOptions.withWarnScalaVersionEviction(false), report).scalaEvictions should have size (0)
|
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() = {
|
def javaLibNoWarn1() = {
|
||||||
val deps = Vector(commonsIo14, commonsIo13)
|
val deps = Vector(commonsIo14, commonsIo13)
|
||||||
val m = module(defaultModuleId, deps, Some("2.10.3"))
|
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() = {
|
def scalaLibNoWarn1() = {
|
||||||
val deps = Vector(scala2104, akkaActor230, akkaActor234)
|
val deps = Vector(scala2104, akkaActor230, akkaActor234)
|
||||||
val m = module(defaultModuleId, deps, Some("2.10.4"))
|
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 =
|
def dummyScalaModuleInfo(v: String): ScalaModuleInfo =
|
||||||
ScalaModuleInfo(
|
ScalaModuleInfo(
|
||||||
scalaFullVersion = v,
|
scalaFullVersion = v,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue