mirror of https://github.com/sbt/sbt.git
Change the sbt API/binary version for sbt 1.x to be 1.0
This commit is contained in:
parent
f98ee86668
commit
039e2e6b6a
|
|
@ -36,12 +36,20 @@ object CrossVersionUtil {
|
|||
* Compatible versions include 0.12.0-1 and 0.12.0-RC1 for Some(0, 12).
|
||||
*/
|
||||
private[sbt] def sbtApiVersion(v: String): Option[(Int, Int)] = v match {
|
||||
case ReleaseV(x, y, _, _) => Some((x.toInt, y.toInt))
|
||||
case CandidateV(x, y, _, _) => Some((x.toInt, y.toInt))
|
||||
case NonReleaseV_n(x, y, z, _) if z.toInt > 0 => Some((x.toInt, y.toInt))
|
||||
case ReleaseV(x, y, _, _) => Some(sbtApiVersion(x.toInt, y.toInt))
|
||||
case CandidateV(x, y, _, _) => Some(sbtApiVersion(x.toInt, y.toInt))
|
||||
case NonReleaseV_n(x, y, z, _) if z.toInt > 0 => Some(sbtApiVersion(x.toInt, y.toInt))
|
||||
case _ => None
|
||||
}
|
||||
|
||||
private def sbtApiVersion(x: Int, y: Int) = {
|
||||
// Prior to sbt 1 the "sbt api version" was the X.Y in the X.Y.Z version.
|
||||
// For example for sbt 0.13.x releases, the sbt api version is 0.13
|
||||
// As of sbt 1 it is now X.0.
|
||||
// This means, for example, that all versions of sbt 1.x have sbt api version 1.0
|
||||
if (x > 0) (x, 0) else (x, y)
|
||||
}
|
||||
|
||||
private[sbt] def isScalaApiCompatible(v: String): Boolean = scalaApiVersion(v).isDefined
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,6 +28,33 @@ class CrossVersionTest extends UnitSpec {
|
|||
it should "for 0.12.1 return Some((0, 12))" in {
|
||||
sbtApiVersion("0.12.1") shouldBe Some((0, 12))
|
||||
}
|
||||
it should "for 1.0.0-M6 return None" in {
|
||||
sbtApiVersion("1.0.0-M6") shouldBe None
|
||||
}
|
||||
it should "for 1.0.0-RC1 return Some((1, 0))" in {
|
||||
sbtApiVersion("1.0.0-RC1") shouldBe Some((1, 0))
|
||||
}
|
||||
it should "for 1.0.0 return Some((1, 0))" in {
|
||||
sbtApiVersion("1.0.0") shouldBe Some((1, 0))
|
||||
}
|
||||
it should "for 1.0.2-M1 return Some((1, 0))" in {
|
||||
sbtApiVersion("1.0.2-M1") shouldBe Some((1, 0))
|
||||
}
|
||||
it should "for 1.0.2-RC1 return Some((1, 0))" in {
|
||||
sbtApiVersion("1.0.2-RC1") shouldBe Some((1, 0))
|
||||
}
|
||||
it should "for 1.0.2 return Some((1, 0))" in {
|
||||
sbtApiVersion("1.0.2") shouldBe Some((1, 0))
|
||||
}
|
||||
it should "for 1.3.0 return Some((1, 0))" in {
|
||||
sbtApiVersion("1.3.0") shouldBe Some((1, 0))
|
||||
}
|
||||
it should "for 1.10.0 return Some((1, 0))" in {
|
||||
sbtApiVersion("1.10.0") shouldBe Some((1, 0))
|
||||
}
|
||||
it should "for 2.0.0 return Some((2, 0))" in {
|
||||
sbtApiVersion("2.0.0") shouldBe Some((2, 0))
|
||||
}
|
||||
|
||||
"isSbtApiCompatible" should "for 0.12.0-M1 return false" in {
|
||||
isSbtApiCompatible("0.12.0-M1") shouldBe false
|
||||
|
|
@ -38,6 +65,33 @@ class CrossVersionTest extends UnitSpec {
|
|||
it should "for 0.12.1-RC1 return true" in {
|
||||
isSbtApiCompatible("0.12.1-RC1") shouldBe true
|
||||
}
|
||||
it should "for 1.0.0-M6 return false" in {
|
||||
isSbtApiCompatible("1.0.0-M6") shouldBe false
|
||||
}
|
||||
it should "for 1.0.0-RC1 return true" in {
|
||||
isSbtApiCompatible("1.0.0-RC1") shouldBe true
|
||||
}
|
||||
it should "for 1.0.0 return true" in {
|
||||
isSbtApiCompatible("1.0.0") shouldBe true
|
||||
}
|
||||
it should "for 1.0.2-M1 return true" in {
|
||||
isSbtApiCompatible("1.0.2-M1") shouldBe true
|
||||
}
|
||||
it should "for 1.0.2-RC1 return true" in {
|
||||
isSbtApiCompatible("1.0.2-RC1") shouldBe true
|
||||
}
|
||||
it should "for 1.0.2 return true" in {
|
||||
isSbtApiCompatible("1.0.2") shouldBe true
|
||||
}
|
||||
it should "for 1.3.0 return true" in {
|
||||
isSbtApiCompatible("1.3.0") shouldBe true
|
||||
}
|
||||
it should "for 1.10.0 return true" in {
|
||||
isSbtApiCompatible("1.10.0") shouldBe true
|
||||
}
|
||||
it should "for 2.0.0 return true" in {
|
||||
isSbtApiCompatible("2.0.0") shouldBe true
|
||||
}
|
||||
|
||||
"binarySbtVersion" should "for 0.11.3 return 0.11.3" in {
|
||||
binarySbtVersion("0.11.3") shouldBe "0.11.3"
|
||||
|
|
@ -60,6 +114,33 @@ class CrossVersionTest extends UnitSpec {
|
|||
it should "for 0.12.1 return 0.12" in {
|
||||
binarySbtVersion("0.12.1") shouldBe "0.12"
|
||||
}
|
||||
it should "for 1.0.0-M6 return 1.0.0-M6" in {
|
||||
binarySbtVersion("1.0.0-M6") shouldBe "1.0.0-M6"
|
||||
}
|
||||
it should "for 1.0.0-RC1 return 1.0" in {
|
||||
binarySbtVersion("1.0.0-RC1") shouldBe "1.0"
|
||||
}
|
||||
it should "for 1.0.0 return 1.0" in {
|
||||
binarySbtVersion("1.0.0") shouldBe "1.0"
|
||||
}
|
||||
it should "for 1.0.2-M1 return 1.0" in {
|
||||
binarySbtVersion("1.0.2-M1") shouldBe "1.0"
|
||||
}
|
||||
it should "for 1.0.2-RC1 return 1.0" in {
|
||||
binarySbtVersion("1.0.2-RC1") shouldBe "1.0"
|
||||
}
|
||||
it should "for 1.0.2 return 1.0" in {
|
||||
binarySbtVersion("1.0.2") shouldBe "1.0"
|
||||
}
|
||||
it should "for 1.3.0 return 1.0" in {
|
||||
binarySbtVersion("1.3.0") shouldBe "1.0"
|
||||
}
|
||||
it should "for 1.10.0 return 1.0" in {
|
||||
binarySbtVersion("1.10.0") shouldBe "1.0"
|
||||
}
|
||||
it should "for 2.0.0 return 2.0" in {
|
||||
binarySbtVersion("2.0.0") shouldBe "2.0"
|
||||
}
|
||||
|
||||
"scalaApiVersion" should "for xyz return None" in {
|
||||
scalaApiVersion("xyz") shouldBe None
|
||||
|
|
|
|||
Loading…
Reference in New Issue