mirror of https://github.com/sbt/sbt.git
fport: CrossVersion.patch
CrossVersion.full strips off -bin-suffix. Ref https://github.com/sbt/sbt/pull/2757
This commit is contained in:
parent
3afc15d075
commit
f495291edd
|
|
@ -144,6 +144,16 @@
|
||||||
],
|
],
|
||||||
"type": "record"
|
"type": "record"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Patch",
|
||||||
|
"namespace": "sbt.librarymanagement",
|
||||||
|
"target": "Scala",
|
||||||
|
"doc": [
|
||||||
|
"Cross-versions a module by stripping off -bin-suffix.",
|
||||||
|
"This is intented for patch-version compatible alternative replacements."
|
||||||
|
],
|
||||||
|
"type": "record"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Full",
|
"name": "Full",
|
||||||
"namespace": "sbt.librarymanagement",
|
"namespace": "sbt.librarymanagement",
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,19 @@ abstract class CrossVersionFunctions {
|
||||||
/** Cross-versions a module with the binary version (typically the binary Scala version). */
|
/** Cross-versions a module with the binary version (typically the binary Scala version). */
|
||||||
def binary: CrossVersion = Binary()
|
def binary: CrossVersion = Binary()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cross-versions a module with the full Scala version excluding any `-bin` suffix.
|
||||||
|
*/
|
||||||
|
def patch: CrossVersion = Patch()
|
||||||
|
|
||||||
|
private[sbt] def patchFun(fullVersion: String): String = {
|
||||||
|
val BinCompatV = """(\d+)\.(\d+)\.(\d+)(-\w+)??-bin(-.*)?""".r
|
||||||
|
fullVersion match {
|
||||||
|
case BinCompatV(x, y, z, w, _) => s"""$x.$y.$z${if (w == null) "" else w}"""
|
||||||
|
case other => other
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private[sbt] def append(s: String): Option[String => String] = Some(x => crossName(x, s))
|
private[sbt] def append(s: String): Option[String => String] = Some(x => crossName(x, s))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -29,6 +42,7 @@ abstract class CrossVersionFunctions {
|
||||||
cross match {
|
cross match {
|
||||||
case _: Disabled => None
|
case _: Disabled => None
|
||||||
case _: Binary => append(binaryVersion)
|
case _: Binary => append(binaryVersion)
|
||||||
|
case _: Patch => append(patchFun(fullVersion))
|
||||||
case _: Full => append(fullVersion)
|
case _: Full => append(fullVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,24 @@ class CrossVersionTest extends UnitSpec {
|
||||||
it should "return binary Scala version for 2.10.1 as 2.10" in {
|
it should "return binary Scala version for 2.10.1 as 2.10" in {
|
||||||
CrossVersion.binaryScalaVersion("2.10.1") shouldBe "2.10"
|
CrossVersion.binaryScalaVersion("2.10.1") shouldBe "2.10"
|
||||||
}
|
}
|
||||||
|
it should "return patch Scala version for 2.11.8 as 2.11.8" in {
|
||||||
|
CrossVersion(CrossVersion.patch, "2.11.8", "dummy").map(_("artefact")) shouldBe Some("artefact_2.11.8")
|
||||||
|
}
|
||||||
|
it should "return patch Scala version for 2.11.8-M1 as 2.11.8-M1" in {
|
||||||
|
CrossVersion(CrossVersion.patch, "2.11.8-M1", "dummy").map(_("artefact")) shouldBe Some("artefact_2.11.8-M1")
|
||||||
|
}
|
||||||
|
it should "return patch Scala version for 2.11.8-RC1 as 2.11.8-RC1" in {
|
||||||
|
CrossVersion(CrossVersion.patch, "2.11.8-RC1", "dummy").map(_("artefact")) shouldBe Some("artefact_2.11.8-RC1")
|
||||||
|
}
|
||||||
|
it should "return patch Scala version for 2.11.8-bin-extra as 2.11.8" in {
|
||||||
|
CrossVersion(CrossVersion.patch, "2.11.8-bin-extra", "dummy").map(_("artefact")) shouldBe Some("artefact_2.11.8")
|
||||||
|
}
|
||||||
|
it should "return patch Scala version for 2.11.8-M1-bin-extra as 2.11.8-M1" in {
|
||||||
|
CrossVersion(CrossVersion.patch, "2.11.8-M1-bin-extra", "dummy").map(_("artefact")) shouldBe Some("artefact_2.11.8-M1")
|
||||||
|
}
|
||||||
|
it should "return patch Scala version for 2.11.8-RC1-bin-extra as 2.11.8-RC1" in {
|
||||||
|
CrossVersion(CrossVersion.patch, "2.11.8-RC1-bin-extra", "dummy").map(_("artefact")) shouldBe Some("artefact_2.11.8-RC1")
|
||||||
|
}
|
||||||
it should "return disabled cross version as equal to a copy" in {
|
it should "return disabled cross version as equal to a copy" in {
|
||||||
Disabled() shouldBe Disabled()
|
Disabled() shouldBe Disabled()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue