mirror of https://github.com/sbt/sbt.git
parent
1ad2ff9295
commit
9c1566dfa1
|
|
@ -84,7 +84,8 @@ object EvictionWarningOptions {
|
|||
)
|
||||
|
||||
lazy val defaultGuess: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] =
|
||||
guessSecondSegment orElse guessSemVer orElse guessFalse
|
||||
guessSbtOne orElse guessSecondSegment orElse guessSemVer orElse guessFalse
|
||||
|
||||
lazy val guessSecondSegment
|
||||
: PartialFunction[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] = {
|
||||
case (m1, Some(m2), Some(scalaModuleInfo))
|
||||
|
|
@ -98,6 +99,21 @@ object EvictionWarningOptions {
|
|||
case _ => false
|
||||
}
|
||||
}
|
||||
|
||||
lazy val guessSbtOne
|
||||
: PartialFunction[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] = {
|
||||
case (m1, Some(m2), Some(scalaModuleInfo))
|
||||
if (m2.organization == "org.scala-sbt") &&
|
||||
(m2.name.endsWith("_" + scalaModuleInfo.scalaFullVersion) ||
|
||||
m2.name.endsWith("_" + scalaModuleInfo.scalaBinaryVersion)) =>
|
||||
(m1.revision, m2.revision) match {
|
||||
case (VersionNumber(ns1, ts1, es1), VersionNumber(ns2, ts2, es2)) =>
|
||||
VersionNumber.SemVer
|
||||
.isCompatible(VersionNumber(ns1, ts1, es1), VersionNumber(ns2, ts2, es2))
|
||||
case _ => false
|
||||
}
|
||||
}
|
||||
|
||||
lazy val guessSemVer
|
||||
: PartialFunction[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] = {
|
||||
case (m1, Some(m2), _) =>
|
||||
|
|
@ -108,6 +124,7 @@ object EvictionWarningOptions {
|
|||
case _ => false
|
||||
}
|
||||
}
|
||||
|
||||
lazy val guessFalse
|
||||
: PartialFunction[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] = {
|
||||
case (_, _, _) => false
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package sbt.librarymanagement
|
||||
|
||||
import sbt.internal.librarymanagement.BaseIvySpecification
|
||||
import sbt.internal.librarymanagement.cross.CrossVersionUtil
|
||||
import sbt.librarymanagement.syntax._
|
||||
import org.scalatest.Assertions._
|
||||
|
||||
class EvictionWarningSpec extends BaseIvySpecification {
|
||||
// This is a specification to check the eviction warnings
|
||||
|
|
@ -42,6 +45,22 @@ class EvictionWarningSpec extends BaseIvySpecification {
|
|||
""" should "be detected as eviction" in scalaLibTransitiveWarn2()
|
||||
it should "print out message about the eviction if it's enabled" in scalaLibTransitiveWarn3()
|
||||
|
||||
"Comparing sbt 0.x" should "use Second Segment Variation semantics" in {
|
||||
val m1 = "org.scala-sbt" % "util-logging" % "0.13.16"
|
||||
val m2 = "org.scala-sbt" % "util-logging" % "0.13.1"
|
||||
assert(
|
||||
EvictionWarningOptions
|
||||
.defaultGuess((m1, Option(m2), Option(dummyScalaModuleInfo("2.10.6")))) == false)
|
||||
}
|
||||
|
||||
"Comparing sbt 1.x" should "use Semantic Versioning semantics" in {
|
||||
val m1 = "org.scala-sbt" % "util-logging_2.12" % "1.0.0"
|
||||
val m2 = "org.scala-sbt" % "util-logging_2.12" % "1.1.0"
|
||||
assert(
|
||||
EvictionWarningOptions
|
||||
.defaultGuess((m1, Option(m2), Option(dummyScalaModuleInfo("2.12.4")))))
|
||||
}
|
||||
|
||||
def akkaActor214 =
|
||||
ModuleID("com.typesafe.akka", "akka-actor", "2.1.4").withConfigurations(Some("compile")) cross CrossVersion.binary
|
||||
def akkaActor230 =
|
||||
|
|
@ -265,4 +284,14 @@ class EvictionWarningSpec extends BaseIvySpecification {
|
|||
"Run 'evicted' to see detailed eviction warnings"
|
||||
)
|
||||
}
|
||||
|
||||
def dummyScalaModuleInfo(v: String): ScalaModuleInfo =
|
||||
ScalaModuleInfo(
|
||||
scalaFullVersion = v,
|
||||
scalaBinaryVersion = CrossVersionUtil.binaryScalaVersion(v),
|
||||
configurations = Vector.empty,
|
||||
checkExplicit = true,
|
||||
filterImplicit = false,
|
||||
overrideScalaVersion = true
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue