mirror of https://github.com/sbt/sbt.git
Allow for some customization in CrossVersion results
The old way to customize CrossVersion results was a `String => String`
function called 'remapVersion', removed in
301ec787f2.
That was removed because it's not possible to serialise Function1s, and
we want to serialise CrossVersion (and therefore ModuleID, etc) to be
able to transfer them in sbt server.
This commit reintroduces a less-powerful way to vary the results of
apply CrossVersion, but just providing the opportunity to define a
suffix. From looking at the users of CrossVersion (Scala.js'
sbt-scalajs-plugin & Scala Native's sbt-crossproject) this looks to be
sufficient.
This commit is contained in:
parent
92cc7c4cb1
commit
87e8d87811
|
|
@ -138,11 +138,12 @@
|
|||
"namespace": "sbt.librarymanagement",
|
||||
"target": "Scala",
|
||||
"doc": [
|
||||
"Cross-versions a module using the result of applying `remapVersion` to the binary version.",
|
||||
"For example, if `remapVersion = v => \"2.10\"` and the binary version is \"2.9.2\" or \"2.10\",",
|
||||
"the module is cross-versioned with \"2.10\"."
|
||||
"Cross-versions a module using the result of appending `suffix` to the binary version.",
|
||||
"For example, if `suffix = \"_foo\"` and the binary version is \"2.10\",",
|
||||
"the module is cross-versioned with \"2.10_foo\"."
|
||||
],
|
||||
"type": "record"
|
||||
"type": "record",
|
||||
"fields": [ { "name": "suffix", "type": "String", "default": "\"\"", "since": "0.0.1" } ]
|
||||
},
|
||||
{
|
||||
"name": "Patch",
|
||||
|
|
@ -150,7 +151,7 @@
|
|||
"target": "Scala",
|
||||
"doc": [
|
||||
"Cross-versions a module by stripping off -bin-suffix.",
|
||||
"This is intented for patch-version compatible alternative replacements."
|
||||
"This is intended for patch-version compatible alternative replacements."
|
||||
],
|
||||
"type": "record"
|
||||
},
|
||||
|
|
@ -160,10 +161,11 @@
|
|||
"target": "Scala",
|
||||
"type": "record",
|
||||
"doc": [
|
||||
"Cross-versions a module with the result of applying `remapVersion` to the full version.",
|
||||
"For example, if `remapVersion = v => \"2.10\"` and the full version is \"2.9.2\" or \"2.10.3\",",
|
||||
"the module is cross-versioned with \"2.10\"."
|
||||
]
|
||||
"Cross-versions a module with the result of appending `suffix` to the full version.",
|
||||
"For example, if `suffix = \"_foo\"` and the full version is \"2.12.1\",",
|
||||
"the module is cross-versioned with \"2.12.1_foo\"."
|
||||
],
|
||||
"fields": [ { "name": "suffix", "type": "String", "default": "\"\"", "since": "0.0.1" } ]
|
||||
}
|
||||
],
|
||||
"parentsCompanion": "sbt.librarymanagement.CrossVersionFunctions"
|
||||
|
|
|
|||
|
|
@ -15,9 +15,21 @@ abstract class CrossVersionFunctions {
|
|||
/** Cross-versions a module with the full version (typically the full Scala version). */
|
||||
def full: CrossVersion = Full()
|
||||
|
||||
/**
|
||||
* Cross-versions a module with the result of appending `suffix` to the full version.
|
||||
* (typically the full Scala version). See also [[sbt.librarymanagement.Full]]
|
||||
*/
|
||||
def fullSuffixed(suffix: String): CrossVersion = Full(suffix)
|
||||
|
||||
/** Cross-versions a module with the binary version (typically the binary Scala version). */
|
||||
def binary: CrossVersion = Binary()
|
||||
|
||||
/**
|
||||
* Cross-versions a module with the result of appending `suffix` to the binary version
|
||||
* (typically the binary Scala version). See also [[sbt.librarymanagement.Binary]].
|
||||
*/
|
||||
def binarySuffixed(suffix: String): CrossVersion = Binary(suffix)
|
||||
|
||||
/**
|
||||
* Cross-versions a module with the full Scala version excluding any `-bin` suffix.
|
||||
*/
|
||||
|
|
@ -41,9 +53,9 @@ abstract class CrossVersionFunctions {
|
|||
def apply(cross: CrossVersion, fullVersion: String, binaryVersion: String): Option[String => String] =
|
||||
cross match {
|
||||
case _: Disabled => None
|
||||
case _: Binary => append(binaryVersion)
|
||||
case b: Binary => append(binaryVersion + b.suffix)
|
||||
case _: Patch => append(patchFun(fullVersion))
|
||||
case _: Full => append(fullVersion)
|
||||
case f: Full => append(fullVersion + f.suffix)
|
||||
}
|
||||
|
||||
/** Constructs the cross-version function defined by `module` and `is`, if one is configured. */
|
||||
|
|
|
|||
Loading…
Reference in New Issue