mirror of https://github.com/sbt/sbt.git
Merge pull request #3361 from eed3si9n/wip/apifix
[bport] Fixes sbtApiVersion logic
This commit is contained in:
commit
5096c3a8c5
|
|
@ -60,6 +60,36 @@ object CrossVersionTest extends Specification {
|
|||
"return binary sbt version for 0.12.1 as 0.12" in {
|
||||
CrossVersion.binarySbtVersion("0.12.1") must_== "0.12"
|
||||
}
|
||||
"return binary sbt version for 1.0.0-M6 as 1.0.0-M6" in {
|
||||
CrossVersion.binarySbtVersion("1.0.0-M6") must_== "1.0.0-M6"
|
||||
}
|
||||
"return binary sbt version for 1.0.0-RC1 as 1.0" in {
|
||||
CrossVersion.binarySbtVersion("1.0.0-RC1") must_== "1.0"
|
||||
}
|
||||
"return binary sbt version for 1.0.0 as 1.0" in {
|
||||
CrossVersion.binarySbtVersion("1.0.0") must_== "1.0"
|
||||
}
|
||||
"return binary sbt version for 1.0.2-M1 as 1.0" in {
|
||||
CrossVersion.binarySbtVersion("1.0.2-M1") must_== "1.0"
|
||||
}
|
||||
"return binary sbt version for 1.0.2-RC1 as 1.0" in {
|
||||
CrossVersion.binarySbtVersion("1.0.2-RC1") must_== "1.0"
|
||||
}
|
||||
"return binary sbt version for 1.0.2 as 1.0" in {
|
||||
CrossVersion.binarySbtVersion("1.0.2") must_== "1.0"
|
||||
}
|
||||
"return binary sbt version for 1.3.0 as 1.0" in {
|
||||
CrossVersion.binarySbtVersion("1.3.0") must_== "1.0"
|
||||
}
|
||||
"return binary sbt version for 1.3.0-SNAPSHOT as 1.0" in {
|
||||
CrossVersion.binarySbtVersion("1.3.0-SNAPSHOT") must_== "1.0"
|
||||
}
|
||||
"return binary sbt version for 1.10.0 as 1.0" in {
|
||||
CrossVersion.binarySbtVersion("1.10.0") must_== "1.0"
|
||||
}
|
||||
"return binary sbt version for 2.0.0 as 2.0" in {
|
||||
CrossVersion.binarySbtVersion("2.0.0") must_== "2.0"
|
||||
}
|
||||
|
||||
"return Scala API for xyz as None" in {
|
||||
CrossVersion.scalaApiVersion("xyz") must_== None
|
||||
|
|
@ -121,11 +151,9 @@ object CrossVersionTest extends Specification {
|
|||
"return binary Scala version for 2.20170314093845.0-87654321 as 2.20170314093845.0-87654321" in {
|
||||
CrossVersion.binaryScalaVersion("2.20170314093845.0-87654321") must_== "2.20170314093845.0-87654321"
|
||||
}
|
||||
|
||||
"return binary Scala version for Dotty 0.1.1 as 0.1" in {
|
||||
CrossVersion.binaryScalaVersion("0.1.1") must_== "0.1"
|
||||
}
|
||||
|
||||
"return patch Scala version for 2.11.8 as 2.11.8" in {
|
||||
CrossVersion(CrossVersion.patch, "2.11.8", "dummy").map(_("artefact")) must_== Some("artefact_2.11.8")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,12 +30,25 @@ object CrossVersionUtil
|
|||
val CandidateV = (basicVersion + """(-RC\d+)""").r
|
||||
val NonReleaseV = (basicVersion + """([-\w+]*)""").r
|
||||
v match {
|
||||
case ReleaseV(x, y, z, ht) => Some((x.toInt, y.toInt))
|
||||
case CandidateV(x, y, z, ht) => Some((x.toInt, y.toInt))
|
||||
case NonReleaseV(x, y, z, ht) if z.toInt > 0 => Some((x.toInt, y.toInt))
|
||||
case ReleaseV(x, y, z, ht) => Some(sbtApiVersion(x.toInt, y.toInt))
|
||||
case CandidateV(x, y, z, ht) => Some(sbtApiVersion(x.toInt, y.toInt))
|
||||
case NonReleaseV(x, y, z, ht) if x.toInt == 0 && z.toInt > 0 =>
|
||||
Some(sbtApiVersion(x.toInt, y.toInt))
|
||||
case NonReleaseV(x, y, z, _) if x.toInt > 0 && (y.toInt > 0 || z.toInt > 0) =>
|
||||
Some(sbtApiVersion(x.toInt, y.toInt))
|
||||
case _ => None
|
||||
}
|
||||
}
|
||||
|
||||
private[${{cross.package0}}] def sbtApiVersion(x: Int, y: Int): (Int, 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[${{cross.package0}}] def isScalaApiCompatible(v: String): Boolean = scalaApiVersion(v).isDefined
|
||||
/** Returns Scala binary interface x.y API compatible with the given version string v.
|
||||
* Compatibile versions include 2.10.0-1 and 2.10.1-M1 for Some(2, 10), but not 2.10.0-RC1.
|
||||
|
|
|
|||
Loading…
Reference in New Issue