mirror of https://github.com/sbt/sbt.git
[2.x] refactor: Hide addPlatformSuffix, keep documented FromSbt duplicate
This commit is contained in:
parent
e2601b7ca6
commit
770fedb72e
|
|
@ -168,17 +168,17 @@ private[librarymanagement] abstract class CrossVersionFunctions {
|
|||
|
||||
/**
|
||||
* Appends the platform suffix (e.g. `native0.5`, `sjs1`) to `name`, preferring an explicit
|
||||
* `platformOpt` over the `projectPlatform`. `""` and `jvm` add no suffix.
|
||||
* `platformOpt` over the `projectPlatform`. `""` and `jvm` add no suffix. Keep in sync with
|
||||
* `lmcoursier.FromSbt.addPlatformSuffix` (until lm-coursier moves under sbt).
|
||||
*/
|
||||
def addPlatformSuffix(
|
||||
private[sbt] def addPlatformSuffix(
|
||||
name: String,
|
||||
platformOpt: Option[String],
|
||||
projectPlatform: Option[String]
|
||||
): String =
|
||||
(platformOpt orElse projectPlatform) match {
|
||||
platformOpt.orElse(projectPlatform) match
|
||||
case Some(p) if p.nonEmpty && p != Platform.jvm => crossName(name, p)
|
||||
case _ => name
|
||||
}
|
||||
|
||||
/** Cross-versions `exclude` according to its `crossVersion`. */
|
||||
private[sbt] def substituteCross(
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ object FromSbt {
|
|||
val name1 =
|
||||
crossVersion match
|
||||
case _: Disabled => name0
|
||||
case _ => CrossVersion.addPlatformSuffix(name0, platformOpt, projectPlatform)
|
||||
case _ => addPlatformSuffix(name0, platformOpt, projectPlatform)
|
||||
val updatedName = CrossVersion(crossVersion, scalaVersion, scalaBinaryVersion)
|
||||
.fold(name1)(_(name1))
|
||||
if (!optionalCrossVer || updatedName.length <= name0.length)
|
||||
|
|
@ -46,6 +46,27 @@ object FromSbt {
|
|||
}
|
||||
}
|
||||
|
||||
// Duplicate of sbt.librarymanagement.CrossVersion.addPlatformSuffix. Keep the two in sync
|
||||
// until lm-coursier moves under sbt
|
||||
private def addPlatformSuffix(
|
||||
name: String,
|
||||
platformOpt: Option[String],
|
||||
projectPlatform: Option[String]
|
||||
): String = {
|
||||
def addSuffix(platformName: String): String =
|
||||
platformName match {
|
||||
case "" | "jvm" => name
|
||||
case _ => s"${name}_$platformName"
|
||||
}
|
||||
(platformOpt, projectPlatform) match {
|
||||
case (Some(p), _) =>
|
||||
addSuffix(p) // Use explicit platform if set (don't override with project platform)
|
||||
case (None, Some(p)) =>
|
||||
addSuffix(p) // Only use project platform if dependency has no explicit platform
|
||||
case _ => name
|
||||
}
|
||||
}
|
||||
|
||||
private def attributes(attr: Map[String, String]): Map[String, String] =
|
||||
attr
|
||||
.map { (k, v) =>
|
||||
|
|
|
|||
Loading…
Reference in New Issue