mirror of https://github.com/sbt/sbt.git
Rename function and extend support to Scala 4+
This commit is contained in:
parent
2318269dc5
commit
daec6265c4
|
|
@ -92,12 +92,18 @@ object CrossVersionUtil {
|
|||
//
|
||||
// - For non-stable Scala 3 versions, compiler versions can read TASTy in an older stable format but their TASTY versions are not compatible between each other even if the compilers have the same minor version (https://docs.scala-lang.org/scala3/reference/language-versions/binary-compatibility.html)
|
||||
//
|
||||
private[sbt] def isBinaryCompatibleWith(newVersion: String, origVersion: String): Boolean = {
|
||||
private[sbt] def isScalaBinaryCompatibleWith(newVersion: String, origVersion: String): Boolean = {
|
||||
(newVersion, origVersion) match {
|
||||
case (NonReleaseV_n("2", nMin, _, _), NonReleaseV_n("2", oMin, _, _)) => nMin == oMin
|
||||
case (ReleaseV("3", nMin, _, _), ReleaseV("3", oMin, _, _)) => nMin.toInt >= oMin.toInt
|
||||
case (NonReleaseV_1("3", nMin, _, _), ReleaseV("3", oMin, _, _)) => nMin.toInt > oMin.toInt
|
||||
case _ => newVersion == origVersion
|
||||
case (NonReleaseV_n("2", nMin, _, _), NonReleaseV_n("2", oMin, _, _)) =>
|
||||
nMin == oMin
|
||||
case (ReleaseV(nMaj, nMin, _, _), ReleaseV(oMaj, oMin, _, _))
|
||||
if nMaj == oMaj && nMaj.toLong >= 3 =>
|
||||
nMin.toInt >= oMin.toInt
|
||||
case (NonReleaseV_1(nMaj, nMin, _, _), ReleaseV(oMaj, oMin, _, _))
|
||||
if nMaj == oMaj && nMaj.toLong >= 3 =>
|
||||
nMin.toInt > oMin.toInt
|
||||
case _ =>
|
||||
newVersion == origVersion
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -239,6 +239,6 @@ private[librarymanagement] abstract class CrossVersionFunctions {
|
|||
/**
|
||||
* Returns `true` if a project targeting version `origVersion` can run with version `newVersion`.
|
||||
*/
|
||||
def isBinaryCompatibleWith(newVersion: String, origVersion: String): Boolean =
|
||||
CrossVersionUtil.isBinaryCompatibleWith(newVersion, origVersion)
|
||||
def isScalaBinaryCompatibleWith(newVersion: String, origVersion: String): Boolean =
|
||||
CrossVersionUtil.isScalaBinaryCompatibleWith(newVersion, origVersion)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,53 +284,53 @@ class CrossVersionTest extends UnitSpec {
|
|||
patchVersion("2.11.8-X1.5-bin-extra") shouldBe Some("artefact_2.11.8-X1.5")
|
||||
}
|
||||
|
||||
"isBinaryCompatibleWith" should "for (2.10.4, 2.10.5) return true" in {
|
||||
isBinaryCompatibleWith("2.10.4", "2.10.5") shouldBe true
|
||||
"isScalaBinaryCompatibleWith" should "for (2.10.4, 2.10.5) return true" in {
|
||||
isScalaBinaryCompatibleWith("2.10.4", "2.10.5") shouldBe true
|
||||
}
|
||||
it should "for (2.10.6, 2.10.5) return true" in {
|
||||
isBinaryCompatibleWith("2.10.6", "2.10.5") shouldBe true
|
||||
isScalaBinaryCompatibleWith("2.10.6", "2.10.5") shouldBe true
|
||||
}
|
||||
it should "for (2.11.0, 2.10.5) return false" in {
|
||||
isBinaryCompatibleWith("2.11.0", "2.10.5") shouldBe false
|
||||
isScalaBinaryCompatibleWith("2.11.0", "2.10.5") shouldBe false
|
||||
}
|
||||
it should "for (3.0.0, 2.10.5) return false" in {
|
||||
isBinaryCompatibleWith("3.0.0", "2.10.5") shouldBe false
|
||||
isScalaBinaryCompatibleWith("3.0.0", "2.10.5") shouldBe false
|
||||
}
|
||||
it should "for (3.0.0, 3.1.0) return false" in {
|
||||
isBinaryCompatibleWith("3.0.0", "3.1.0") shouldBe false
|
||||
isScalaBinaryCompatibleWith("3.0.0", "3.1.0") shouldBe false
|
||||
}
|
||||
it should "for (3.1.0, 3.0.0) return true" in {
|
||||
isBinaryCompatibleWith("3.1.0", "3.0.0") shouldBe true
|
||||
isScalaBinaryCompatibleWith("3.1.0", "3.0.0") shouldBe true
|
||||
}
|
||||
it should "for (3.1.0, 3.1.1) return true" in {
|
||||
isBinaryCompatibleWith("3.1.0", "3.1.1") shouldBe true
|
||||
isScalaBinaryCompatibleWith("3.1.0", "3.1.1") shouldBe true
|
||||
}
|
||||
it should "for (3.1.1, 3.1.0) return true" in {
|
||||
isBinaryCompatibleWith("3.1.1", "3.1.0") shouldBe true
|
||||
isScalaBinaryCompatibleWith("3.1.1", "3.1.0") shouldBe true
|
||||
}
|
||||
it should "for (2.10.0-M1, 2.10.5) return true" in {
|
||||
isBinaryCompatibleWith("2.10.0-M1", "2.10.5") shouldBe true
|
||||
isScalaBinaryCompatibleWith("2.10.0-M1", "2.10.5") shouldBe true
|
||||
}
|
||||
it should "for (2.10.5, 2.10.0-M1) return true" in {
|
||||
isBinaryCompatibleWith("2.10.5", "2.10.0-M1") shouldBe true
|
||||
isScalaBinaryCompatibleWith("2.10.5", "2.10.0-M1") shouldBe true
|
||||
}
|
||||
it should "for (2.10.0-M1, 2.10.0-M2) return true" in {
|
||||
isBinaryCompatibleWith("2.10.0-M1", "2.10.0-M2") shouldBe true
|
||||
isScalaBinaryCompatibleWith("2.10.0-M1", "2.10.0-M2") shouldBe true
|
||||
}
|
||||
it should "for (2.10.0-M1, 2.11.0-M1) return false" in {
|
||||
isBinaryCompatibleWith("2.10.0-M1", "2.11.0-M1") shouldBe false
|
||||
isScalaBinaryCompatibleWith("2.10.0-M1", "2.11.0-M1") shouldBe false
|
||||
}
|
||||
it should "for (3.1.0-M1, 3.0.0) return true" in {
|
||||
isBinaryCompatibleWith("3.1.0-M1", "3.0.0") shouldBe true
|
||||
isScalaBinaryCompatibleWith("3.1.0-M1", "3.0.0") shouldBe true
|
||||
}
|
||||
it should "for (3.1.0-M1, 3.1.0) return false" in {
|
||||
isBinaryCompatibleWith("3.1.0-M1", "3.1.0") shouldBe false
|
||||
isScalaBinaryCompatibleWith("3.1.0-M1", "3.1.0") shouldBe false
|
||||
}
|
||||
it should "for (3.1.0-M1, 3.1.0-M2) return false" in {
|
||||
isBinaryCompatibleWith("3.1.0-M1", "3.1.0-M2") shouldBe false
|
||||
isScalaBinaryCompatibleWith("3.1.0-M1", "3.1.0-M2") shouldBe false
|
||||
}
|
||||
it should "for (3.1.0-M2, 3.1.0-M1) return false" in {
|
||||
isBinaryCompatibleWith("3.1.0-M2", "3.1.0-M1") shouldBe false
|
||||
isScalaBinaryCompatibleWith("3.1.0-M2", "3.1.0-M1") shouldBe false
|
||||
}
|
||||
|
||||
private def constantVersion(value: String) =
|
||||
|
|
|
|||
Loading…
Reference in New Issue