mirror of https://github.com/sbt/sbt.git
Fix MatchError when using cross version patch with sbt 1.0
This commit is contained in:
parent
ce1ebc0124
commit
d077a82341
|
|
@ -18,10 +18,6 @@ object SbtCompatibility {
|
||||||
|
|
||||||
type IvySbt = sbt.IvySbt
|
type IvySbt = sbt.IvySbt
|
||||||
|
|
||||||
type Binary = sbt.CrossVersion.Binary
|
|
||||||
type Disabled = sbt.CrossVersion.Disabled.type
|
|
||||||
type Full = sbt.CrossVersion.Full
|
|
||||||
|
|
||||||
implicit class ModuleIDOps(val id: sbt.ModuleID) extends AnyVal {
|
implicit class ModuleIDOps(val id: sbt.ModuleID) extends AnyVal {
|
||||||
def withConfigurations(configurations: Option[String]): sbt.ModuleID =
|
def withConfigurations(configurations: Option[String]): sbt.ModuleID =
|
||||||
id.copy(configurations = configurations)
|
id.copy(configurations = configurations)
|
||||||
|
|
|
||||||
|
|
@ -16,20 +16,6 @@ object SbtCompatibility {
|
||||||
|
|
||||||
type IvySbt = sbt.internal.librarymanagement.IvySbt
|
type IvySbt = sbt.internal.librarymanagement.IvySbt
|
||||||
|
|
||||||
type Binary = sbt.librarymanagement.Binary
|
|
||||||
type Disabled = sbt.librarymanagement.Disabled
|
|
||||||
type Full = sbt.librarymanagement.Full
|
|
||||||
|
|
||||||
implicit class BinaryOps(private val binary: Binary) extends AnyVal {
|
|
||||||
def remapVersion(scalaBinaryVersion: String): String =
|
|
||||||
binary.prefix + scalaBinaryVersion + binary.suffix
|
|
||||||
}
|
|
||||||
|
|
||||||
implicit class FullOps(private val full: Full) extends AnyVal {
|
|
||||||
def remapVersion(scalaVersion: String): String =
|
|
||||||
full.prefix + scalaVersion + full.suffix
|
|
||||||
}
|
|
||||||
|
|
||||||
def needsIvyXmlLocal = sbt.Keys.publishLocalConfiguration
|
def needsIvyXmlLocal = sbt.Keys.publishLocalConfiguration
|
||||||
def needsIvyXml = sbt.Keys.publishConfiguration
|
def needsIvyXml = sbt.Keys.publishConfiguration
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,9 @@ object FromSbt {
|
||||||
crossVersion: CrossVersion,
|
crossVersion: CrossVersion,
|
||||||
scalaVersion: => String,
|
scalaVersion: => String,
|
||||||
scalaBinaryVersion: => String
|
scalaBinaryVersion: => String
|
||||||
): String = crossVersion match {
|
): String =
|
||||||
case _: Disabled => name
|
CrossVersion(crossVersion, scalaVersion, scalaBinaryVersion)
|
||||||
case f: Full => name + "_" + f.remapVersion(scalaVersion)
|
.fold(name)(_(name))
|
||||||
case b: Binary => name + "_" + b.remapVersion(scalaBinaryVersion)
|
|
||||||
}
|
|
||||||
|
|
||||||
def attributes(attr: Map[String, String]): Map[String, String] =
|
def attributes(attr: Map[String, String]): Map[String, String] =
|
||||||
attr.map { case (k, v) =>
|
attr.map { case (k, v) =>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
|
import Compatibility._
|
||||||
|
|
||||||
scalaVersion := "2.12.2-bin-typelevel-4"
|
scalaVersion := "2.12.2-bin-typelevel-4"
|
||||||
scalaOrganization := "org.typelevel"
|
scalaOrganization := "org.typelevel"
|
||||||
scalacOptions += "-Yinduction-heuristics"
|
scalacOptions += "-Yinduction-heuristics"
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"com.47deg" %% "freestyle" % "0.1.0",
|
"com.47deg" %% "freestyle" % "0.1.0",
|
||||||
// CrossVersion.patch not available in sbt 0.13.8
|
compilerPlugin("org.scalamacros" %% "paradise" % "2.1.0" cross CrossVersion.patch)
|
||||||
compilerPlugin("org.scalamacros" % "paradise_2.12.2" % "2.1.0")
|
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
object Compatibility {
|
||||||
|
|
||||||
|
// patch method not available in sbt 0.13.8
|
||||||
|
|
||||||
|
implicit class CrossVersionOps(val companion: sbt.CrossVersion.type) extends AnyVal {
|
||||||
|
def patch: sbt.CrossVersion = new sbt.CrossVersion.Full(patchFun)
|
||||||
|
}
|
||||||
|
|
||||||
|
// adapted from sbt.CrossVersion from the sbt 0.13.16 sources
|
||||||
|
|
||||||
|
private val BinCompatV = """(\d+)\.(\d+)\.(\d+)(-\w+)??-bin(-.*)?""".r
|
||||||
|
|
||||||
|
private def patchFun(fullVersion: String): String =
|
||||||
|
fullVersion match {
|
||||||
|
case BinCompatV(x, y, z, w, _) => s"""$x.$y.$z${if (w == null) "" else w}"""
|
||||||
|
case other => other
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
object Compatibility
|
||||||
Loading…
Reference in New Issue