mirror of https://github.com/sbt/sbt.git
parent
0ce5142b17
commit
ae9f17c8fc
|
|
@ -22,12 +22,13 @@ object CrossVersionUtil {
|
|||
|
||||
private val longPattern = """\d{1,19}"""
|
||||
private val basicVersion = raw"""($longPattern)\.($longPattern)\.($longPattern)"""
|
||||
private val tagPattern = raw"""(?:\w+(?:\.\w+)*)"""
|
||||
private val ReleaseV = raw"""$basicVersion(-\d+)?""".r
|
||||
private val BinCompatV = raw"""$basicVersion(-\w+)?-bin(-.*)?""".r
|
||||
private[sbt] val BinCompatV = raw"""$basicVersion(-$tagPattern)?-bin(-.*)?""".r
|
||||
private val CandidateV = raw"""$basicVersion(-RC\d+)""".r
|
||||
private val MilestonV = raw"""$basicVersion(-M\d+)""".r
|
||||
private val NonReleaseV_n = raw"""$basicVersion([-\w]*)""".r // 0-n word suffixes, with leading dashes
|
||||
private val NonReleaseV_1 = raw"""$basicVersion(-\w+)""".r // 1 word suffix, after a dash
|
||||
private val MilestonV = raw"""$basicVersion(-M$tagPattern)""".r
|
||||
private val NonReleaseV_n = raw"""$basicVersion((?:-$tagPattern)*)""".r // 0-n word suffixes, with leading dashes
|
||||
private val NonReleaseV_1 = raw"""$basicVersion(-$tagPattern)""".r // 1 word suffix, after a dash
|
||||
private[sbt] val PartialVersion = raw"""($longPattern)\.($longPattern)(?:\..+)?""".r
|
||||
|
||||
private[sbt] def isSbtApiCompatible(v: String): Boolean = sbtApiVersion(v).isDefined
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ private[librarymanagement] abstract class CrossVersionFunctions {
|
|||
}
|
||||
|
||||
private[sbt] def patchFun(fullVersion: String): String = {
|
||||
val BinCompatV = """(\d+)\.(\d+)\.(\d+)(-\w+)??-bin(-.*)?""".r
|
||||
import sbt.internal.librarymanagement.cross.CrossVersionUtil.BinCompatV
|
||||
fullVersion match {
|
||||
case BinCompatV(x, y, z, w, _) => s"""$x.$y.$z${if (w == null) "" else w}"""
|
||||
case other => other
|
||||
|
|
|
|||
|
|
@ -138,6 +138,9 @@ class CrossVersionTest extends UnitSpec {
|
|||
it should "for 1.3.0-SNAPSHOT return 1.0" in {
|
||||
binarySbtVersion("1.3.0-SNAPSHOT") shouldBe "1.0"
|
||||
}
|
||||
it should "for 1.3.0-A1-B1.1 return 1.0" in {
|
||||
binarySbtVersion("1.3.0-A1-B1.1") shouldBe "1.0"
|
||||
}
|
||||
it should "for 1.10.0 return 1.0" in {
|
||||
binarySbtVersion("1.10.0") shouldBe "1.0"
|
||||
}
|
||||
|
|
@ -216,6 +219,9 @@ class CrossVersionTest extends UnitSpec {
|
|||
it should "for 3.0.0-M3-bin-20201215-cbe50b3-NIGHTLY return 3.0.0-M3" in {
|
||||
binaryScalaVersion("3.0.0-M3-bin-20201215-cbe50b3-NIGHTLY") shouldBe "3.0.0-M3"
|
||||
}
|
||||
it should "for 3.0.0-M3.5-bin-20201215-cbe50b3-NIGHTLY return 3.0.0-M3" in {
|
||||
binaryScalaVersion("3.0.0-M3.5-bin-20201215-cbe50b3-NIGHTLY") shouldBe "3.0.0-M3.5"
|
||||
}
|
||||
it should "for 3.0.0-RC1 return 3.0.0-RC1" in {
|
||||
binaryScalaVersion("3.0.0-RC1") shouldBe "3.0.0-RC1"
|
||||
}
|
||||
|
|
@ -268,6 +274,9 @@ class CrossVersionTest extends UnitSpec {
|
|||
it should "for 2.11.8-RC1-bin-extra return 2.11.8-RC1" in {
|
||||
patchVersion("2.11.8-RC1-bin-extra") shouldBe Some("artefact_2.11.8-RC1")
|
||||
}
|
||||
it should "for 2.11.8-X1.5-bin-extra return 2.11.8-X1.5" in {
|
||||
patchVersion("2.11.8-X1.5-bin-extra") shouldBe Some("artefact_2.11.8-X1.5")
|
||||
}
|
||||
|
||||
private def constantVersion(value: String) =
|
||||
CrossVersion(CrossVersion.constant(value), "dummy1", "dummy2") map (fn => fn("artefact"))
|
||||
|
|
|
|||
Loading…
Reference in New Issue