mirror of https://github.com/sbt/sbt.git
Add constant CrossVersion
sbt 1 removes CrossVersion.binaryMapped which was used in the sbt-dotty plugin to provide a way to depend on Scala 2.x artifacts in a project that cross-compiles between Scala 2.x and Dotty (see `withDottyCompat()` in https://github.com/lampepfl/dotty/blob/master/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala). Using `binaryWith` is not enough because it only allows the user to specify a prefix and a suffix for the binary version which will always be set to `scalaBinaryVersion`. This commit introduces a new `Constant` kind of CrossVersion which allows the user to specify any string he wants as a cross-version, thus making it possible to port `withDottyCompat()` to sbt 1.
This commit is contained in:
parent
0bb1aa7120
commit
aaf471dd36
|
|
@ -150,6 +150,18 @@
|
|||
{ "name": "suffix", "type": "String", "default": "\"\"", "since": "0.0.1" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Constant",
|
||||
"namespace": "sbt.librarymanagement",
|
||||
"target": "Scala",
|
||||
"doc": [
|
||||
"Cross-versions a module using the string `value`."
|
||||
],
|
||||
"type": "record",
|
||||
"fields": [
|
||||
{ "name": "value", "type": "String", "default": "\"\"", "since": "0.0.2" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Patch",
|
||||
"namespace": "sbt.librarymanagement",
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ abstract class CrossVersionFunctions {
|
|||
/** Cross-versions a module with the binary version (typically the binary Scala version). */
|
||||
def binary: CrossVersion = Binary()
|
||||
|
||||
/** Cross-versions a module with a constant string (typically the binary Scala version). */
|
||||
def constant(value: String): CrossVersion = Constant(value)
|
||||
|
||||
/**
|
||||
* Cross-versions a module with the result of prepending `prefix` and appending `suffix` to the binary version
|
||||
* (typically the binary Scala version). See also [[sbt.librarymanagement.Binary]].
|
||||
|
|
@ -58,6 +61,7 @@ abstract class CrossVersionFunctions {
|
|||
cross match {
|
||||
case _: Disabled => None
|
||||
case b: Binary => append(b.prefix + binaryVersion + b.suffix)
|
||||
case c: Constant => append(c.value)
|
||||
case _: Patch => append(patchFun(fullVersion))
|
||||
case f: Full => append(f.prefix + fullVersion + f.suffix)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue