diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/Binary.scala b/core/src/main/contraband-scala/sbt/librarymanagement/Binary.scala deleted file mode 100644 index 3cc75b32..00000000 --- a/core/src/main/contraband-scala/sbt/librarymanagement/Binary.scala +++ /dev/null @@ -1,43 +0,0 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY -package sbt.librarymanagement -/** - * Cross-versions a module using the result of - * prepending `prefix` and appending `suffix` to the binary version. - * For example, if `prefix = "foo_"` and `suffix = "_bar"` and the binary version is "2.10", - * the module is cross-versioned with "foo_2.10_bar". - */ -final class Binary private ( - val prefix: String, - val suffix: String) extends sbt.librarymanagement.CrossVersion() with Serializable { - - private def this() = this("", "") - - override def equals(o: Any): Boolean = o match { - case x: Binary => (this.prefix == x.prefix) && (this.suffix == x.suffix) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (17 + "sbt.librarymanagement.Binary".##) + prefix.##) + suffix.##) - } - override def toString: String = { - "Binary(" + prefix + ", " + suffix + ")" - } - private[this] def copy(prefix: String = prefix, suffix: String = suffix): Binary = { - new Binary(prefix, suffix) - } - def withPrefix(prefix: String): Binary = { - copy(prefix = prefix) - } - def withSuffix(suffix: String): Binary = { - copy(suffix = suffix) - } -} -object Binary { - - def apply(): Binary = new Binary() - def apply(prefix: String, suffix: String): Binary = new Binary(prefix, suffix) -} diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/BinaryFormats.scala b/core/src/main/contraband-scala/sbt/librarymanagement/BinaryFormats.scala deleted file mode 100644 index 95bf74af..00000000 --- a/core/src/main/contraband-scala/sbt/librarymanagement/BinaryFormats.scala +++ /dev/null @@ -1,29 +0,0 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY -package sbt.librarymanagement -import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } -trait BinaryFormats { self: sjsonnew.BasicJsonProtocol => -implicit lazy val BinaryFormat: JsonFormat[sbt.librarymanagement.Binary] = new JsonFormat[sbt.librarymanagement.Binary] { - override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.librarymanagement.Binary = { - jsOpt match { - case Some(js) => - unbuilder.beginObject(js) - val prefix = unbuilder.readField[String]("prefix") - val suffix = unbuilder.readField[String]("suffix") - unbuilder.endObject() - sbt.librarymanagement.Binary(prefix, suffix) - case None => - deserializationError("Expected JsObject but found None") - } - } - override def write[J](obj: sbt.librarymanagement.Binary, builder: Builder[J]): Unit = { - builder.beginObject() - builder.addField("prefix", obj.prefix) - builder.addField("suffix", obj.suffix) - builder.endObject() - } -} -} diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/Constant.scala b/core/src/main/contraband-scala/sbt/librarymanagement/Constant.scala deleted file mode 100644 index 8380dccf..00000000 --- a/core/src/main/contraband-scala/sbt/librarymanagement/Constant.scala +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY -package sbt.librarymanagement -/** Cross-versions a module using the string `value`. */ -final class Constant private ( - val value: String) extends sbt.librarymanagement.CrossVersion() with Serializable { - - private def this() = this("") - - override def equals(o: Any): Boolean = o match { - case x: Constant => (this.value == x.value) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (17 + "sbt.librarymanagement.Constant".##) + value.##) - } - override def toString: String = { - "Constant(" + value + ")" - } - private[this] def copy(value: String = value): Constant = { - new Constant(value) - } - def withValue(value: String): Constant = { - copy(value = value) - } -} -object Constant { - - def apply(): Constant = new Constant() - def apply(value: String): Constant = new Constant(value) -} diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/ConstantFormats.scala b/core/src/main/contraband-scala/sbt/librarymanagement/ConstantFormats.scala deleted file mode 100644 index 752adb67..00000000 --- a/core/src/main/contraband-scala/sbt/librarymanagement/ConstantFormats.scala +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY -package sbt.librarymanagement -import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } -trait ConstantFormats { self: sjsonnew.BasicJsonProtocol => -implicit lazy val ConstantFormat: JsonFormat[sbt.librarymanagement.Constant] = new JsonFormat[sbt.librarymanagement.Constant] { - override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.librarymanagement.Constant = { - jsOpt match { - case Some(js) => - unbuilder.beginObject(js) - val value = unbuilder.readField[String]("value") - unbuilder.endObject() - sbt.librarymanagement.Constant(value) - case None => - deserializationError("Expected JsObject but found None") - } - } - override def write[J](obj: sbt.librarymanagement.Constant, builder: Builder[J]): Unit = { - builder.beginObject() - builder.addField("value", obj.value) - builder.endObject() - } -} -} diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/CrossVersion.scala b/core/src/main/contraband-scala/sbt/librarymanagement/CrossVersion.scala deleted file mode 100644 index 2c890a27..00000000 --- a/core/src/main/contraband-scala/sbt/librarymanagement/CrossVersion.scala +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY -package sbt.librarymanagement -/** Configures how a module will be cross-versioned. */ -abstract class CrossVersion() extends Serializable { - - - - -override def equals(o: Any): Boolean = o match { - case _: CrossVersion => true - case _ => false -} -override def hashCode: Int = { - 37 * (17 + "sbt.librarymanagement.CrossVersion".##) -} -override def toString: String = { - "CrossVersion()" -} -} -object CrossVersion extends sbt.librarymanagement.CrossVersionFunctions { - -} diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/CrossVersionFormats.scala b/core/src/main/contraband-scala/sbt/librarymanagement/CrossVersionFormats.scala deleted file mode 100644 index b0b37e91..00000000 --- a/core/src/main/contraband-scala/sbt/librarymanagement/CrossVersionFormats.scala +++ /dev/null @@ -1,11 +0,0 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY -package sbt.librarymanagement - -import _root_.sjsonnew.JsonFormat -trait CrossVersionFormats { self: sjsonnew.BasicJsonProtocol with sbt.librarymanagement.DisabledFormats with sbt.librarymanagement.BinaryFormats with sbt.librarymanagement.ConstantFormats with sbt.librarymanagement.PatchFormats with sbt.librarymanagement.FullFormats => -implicit lazy val CrossVersionFormat: JsonFormat[sbt.librarymanagement.CrossVersion] = flatUnionFormat5[sbt.librarymanagement.CrossVersion, sbt.librarymanagement.Disabled, sbt.librarymanagement.Binary, sbt.librarymanagement.Constant, sbt.librarymanagement.Patch, sbt.librarymanagement.Full]("type") -} diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/Disabled.scala b/core/src/main/contraband-scala/sbt/librarymanagement/Disabled.scala deleted file mode 100644 index 4dbfc38d..00000000 --- a/core/src/main/contraband-scala/sbt/librarymanagement/Disabled.scala +++ /dev/null @@ -1,30 +0,0 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY -package sbt.librarymanagement -/** Disables cross versioning for a module. */ -sealed class Disabled private () extends sbt.librarymanagement.CrossVersion() with Serializable { - - - -override def equals(o: Any): Boolean = o match { - case _: Disabled => true - case _ => false -} -override def hashCode: Int = { - 37 * (17 + "sbt.librarymanagement.Disabled".##) -} -override def toString: String = { - "Disabled()" -} -private[this] def copy(): Disabled = { - new Disabled() -} - -} -object Disabled extends sbt.librarymanagement.Disabled { - - def apply(): Disabled = new Disabled() -} diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/Full.scala b/core/src/main/contraband-scala/sbt/librarymanagement/Full.scala deleted file mode 100644 index cd2416d7..00000000 --- a/core/src/main/contraband-scala/sbt/librarymanagement/Full.scala +++ /dev/null @@ -1,43 +0,0 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY -package sbt.librarymanagement -/** - * Cross-versions a module with the result of - * prepending `prefix` and appending `suffix` to the full version. - * For example, if `prefix = "foo_"` and `suffix = "_bar"` and the full version is "2.12.1", - * the module is cross-versioned with "foo_2.12.1_bar". - */ -final class Full private ( - val prefix: String, - val suffix: String) extends sbt.librarymanagement.CrossVersion() with Serializable { - - private def this() = this("", "") - - override def equals(o: Any): Boolean = o match { - case x: Full => (this.prefix == x.prefix) && (this.suffix == x.suffix) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (17 + "sbt.librarymanagement.Full".##) + prefix.##) + suffix.##) - } - override def toString: String = { - "Full(" + prefix + ", " + suffix + ")" - } - private[this] def copy(prefix: String = prefix, suffix: String = suffix): Full = { - new Full(prefix, suffix) - } - def withPrefix(prefix: String): Full = { - copy(prefix = prefix) - } - def withSuffix(suffix: String): Full = { - copy(suffix = suffix) - } -} -object Full { - - def apply(): Full = new Full() - def apply(prefix: String, suffix: String): Full = new Full(prefix, suffix) -} diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/FullFormats.scala b/core/src/main/contraband-scala/sbt/librarymanagement/FullFormats.scala deleted file mode 100644 index c44b95ef..00000000 --- a/core/src/main/contraband-scala/sbt/librarymanagement/FullFormats.scala +++ /dev/null @@ -1,29 +0,0 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY -package sbt.librarymanagement -import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } -trait FullFormats { self: sjsonnew.BasicJsonProtocol => -implicit lazy val FullFormat: JsonFormat[sbt.librarymanagement.Full] = new JsonFormat[sbt.librarymanagement.Full] { - override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.librarymanagement.Full = { - jsOpt match { - case Some(js) => - unbuilder.beginObject(js) - val prefix = unbuilder.readField[String]("prefix") - val suffix = unbuilder.readField[String]("suffix") - unbuilder.endObject() - sbt.librarymanagement.Full(prefix, suffix) - case None => - deserializationError("Expected JsObject but found None") - } - } - override def write[J](obj: sbt.librarymanagement.Full, builder: Builder[J]): Unit = { - builder.beginObject() - builder.addField("prefix", obj.prefix) - builder.addField("suffix", obj.suffix) - builder.endObject() - } -} -} diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/InclExclRuleFormats.scala b/core/src/main/contraband-scala/sbt/librarymanagement/InclExclRuleFormats.scala index ed1878b6..e7f9ac83 100644 --- a/core/src/main/contraband-scala/sbt/librarymanagement/InclExclRuleFormats.scala +++ b/core/src/main/contraband-scala/sbt/librarymanagement/InclExclRuleFormats.scala @@ -5,7 +5,7 @@ // DO NOT EDIT MANUALLY package sbt.librarymanagement import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } -trait InclExclRuleFormats { self: sbt.librarymanagement.ConfigRefFormats with sbt.librarymanagement.CrossVersionFormats with sjsonnew.BasicJsonProtocol => +trait InclExclRuleFormats { self: sbt.librarymanagement.ConfigRefFormats with sbt.librarymanagement.CrossVersionFormats with sbt.librarymanagement.DisabledFormats with sbt.librarymanagement.BinaryFormats with sbt.librarymanagement.ConstantFormats with sbt.librarymanagement.PatchFormats with sbt.librarymanagement.FullFormats with sjsonnew.BasicJsonProtocol => implicit lazy val InclExclRuleFormat: JsonFormat[sbt.librarymanagement.InclExclRule] = new JsonFormat[sbt.librarymanagement.InclExclRule] { override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.librarymanagement.InclExclRule = { jsOpt match { diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/LibraryManagementCodec.scala b/core/src/main/contraband-scala/sbt/librarymanagement/LibraryManagementCodec.scala index 493571ed..6c82fab1 100644 --- a/core/src/main/contraband-scala/sbt/librarymanagement/LibraryManagementCodec.scala +++ b/core/src/main/contraband-scala/sbt/librarymanagement/LibraryManagementCodec.scala @@ -13,12 +13,12 @@ trait LibraryManagementCodec extends sjsonnew.BasicJsonProtocol with sbt.librarymanagement.UpdateConfigurationFormats with sbt.librarymanagement.ChecksumFormats with sbt.librarymanagement.ArtifactFormats + with sbt.librarymanagement.CrossVersionFormats with sbt.librarymanagement.DisabledFormats with sbt.librarymanagement.BinaryFormats with sbt.librarymanagement.ConstantFormats with sbt.librarymanagement.PatchFormats with sbt.librarymanagement.FullFormats - with sbt.librarymanagement.CrossVersionFormats with sbt.librarymanagement.InclExclRuleFormats with sbt.librarymanagement.ModuleIDFormats with sbt.librarymanagement.ConfigurationFormats diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/ModuleIDFormats.scala b/core/src/main/contraband-scala/sbt/librarymanagement/ModuleIDFormats.scala index 55d0d2fc..eeebd0d3 100644 --- a/core/src/main/contraband-scala/sbt/librarymanagement/ModuleIDFormats.scala +++ b/core/src/main/contraband-scala/sbt/librarymanagement/ModuleIDFormats.scala @@ -5,7 +5,7 @@ // DO NOT EDIT MANUALLY package sbt.librarymanagement import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } -trait ModuleIDFormats { self: sbt.librarymanagement.ArtifactFormats with sbt.librarymanagement.InclExclRuleFormats with sbt.librarymanagement.CrossVersionFormats with sjsonnew.BasicJsonProtocol => +trait ModuleIDFormats { self: sbt.librarymanagement.ArtifactFormats with sbt.librarymanagement.InclExclRuleFormats with sbt.librarymanagement.CrossVersionFormats with sbt.librarymanagement.DisabledFormats with sbt.librarymanagement.BinaryFormats with sbt.librarymanagement.ConstantFormats with sbt.librarymanagement.PatchFormats with sbt.librarymanagement.FullFormats with sjsonnew.BasicJsonProtocol => implicit lazy val ModuleIDFormat: JsonFormat[sbt.librarymanagement.ModuleID] = new JsonFormat[sbt.librarymanagement.ModuleID] { override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.librarymanagement.ModuleID = { jsOpt match { diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/Patch.scala b/core/src/main/contraband-scala/sbt/librarymanagement/Patch.scala deleted file mode 100644 index 217f7583..00000000 --- a/core/src/main/contraband-scala/sbt/librarymanagement/Patch.scala +++ /dev/null @@ -1,33 +0,0 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY -package sbt.librarymanagement -/** - * Cross-versions a module by stripping off -bin-suffix. - * This is intended for patch-version compatible alternative replacements. - */ -final class Patch private () extends sbt.librarymanagement.CrossVersion() with Serializable { - - - -override def equals(o: Any): Boolean = o match { - case _: Patch => true - case _ => false -} -override def hashCode: Int = { - 37 * (17 + "sbt.librarymanagement.Patch".##) -} -override def toString: String = { - "Patch()" -} -private[this] def copy(): Patch = { - new Patch() -} - -} -object Patch { - - def apply(): Patch = new Patch() -} diff --git a/core/src/main/contraband-scala/sbt/librarymanagement/PatchFormats.scala b/core/src/main/contraband-scala/sbt/librarymanagement/PatchFormats.scala deleted file mode 100644 index c419fcb6..00000000 --- a/core/src/main/contraband-scala/sbt/librarymanagement/PatchFormats.scala +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY -package sbt.librarymanagement -import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } -trait PatchFormats { self: sjsonnew.BasicJsonProtocol => -implicit lazy val PatchFormat: JsonFormat[sbt.librarymanagement.Patch] = new JsonFormat[sbt.librarymanagement.Patch] { - override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.librarymanagement.Patch = { - jsOpt match { - case Some(js) => - unbuilder.beginObject(js) - - unbuilder.endObject() - sbt.librarymanagement.Patch() - case None => - deserializationError("Expected JsObject but found None") - } - } - override def write[J](obj: sbt.librarymanagement.Patch, builder: Builder[J]): Unit = { - builder.beginObject() - - builder.endObject() - } -} -} diff --git a/core/src/main/contraband/librarymanagement.json b/core/src/main/contraband/librarymanagement.json index 10c8fd86..52cb3490 100644 --- a/core/src/main/contraband/librarymanagement.json +++ b/core/src/main/contraband/librarymanagement.json @@ -249,79 +249,6 @@ ], "parentsCompanion": "sbt.librarymanagement.ConflictManagerFunctions" }, - { - "name": "CrossVersion", - "namespace": "sbt.librarymanagement", - "target": "Scala", - "type": "interface", - "doc": "Configures how a module will be cross-versioned.", - "types": [ - { - "name": "Disabled", - "namespace": "sbt.librarymanagement", - "target": "Scala", - "doc": "Disables cross versioning for a module.", - "type": "record", - "modifier": "sealed", - "parentsCompanion": "sbt.librarymanagement.Disabled" - }, - { - "name": "Binary", - "namespace": "sbt.librarymanagement", - "target": "Scala", - "doc": [ - "Cross-versions a module using the result of", - "prepending `prefix` and appending `suffix` to the binary version.", - "For example, if `prefix = \"foo_\"` and `suffix = \"_bar\"` and the binary version is \"2.10\",", - "the module is cross-versioned with \"foo_2.10_bar\"." - ], - "type": "record", - "fields": [ - { "name": "prefix", "type": "String", "default": "\"\"", "since": "0.0.1" }, - { "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", - "target": "Scala", - "doc": [ - "Cross-versions a module by stripping off -bin-suffix.", - "This is intended for patch-version compatible alternative replacements." - ], - "type": "record" - }, - { - "name": "Full", - "namespace": "sbt.librarymanagement", - "target": "Scala", - "type": "record", - "doc": [ - "Cross-versions a module with the result of", - "prepending `prefix` and appending `suffix` to the full version.", - "For example, if `prefix = \"foo_\"` and `suffix = \"_bar\"` and the full version is \"2.12.1\",", - "the module is cross-versioned with \"foo_2.12.1_bar\"." - ], - "fields": [ - { "name": "prefix", "type": "String", "default": "\"\"", "since": "0.0.1" }, - { "name": "suffix", "type": "String", "default": "\"\"", "since": "0.0.1" } - ] - } - ], - "parentsCompanion": "sbt.librarymanagement.CrossVersionFunctions" - }, { "name": "Developer", "namespace": "sbt.librarymanagement", diff --git a/core/src/main/scala/sbt/librarymanagement/CrossVersion.scala b/core/src/main/scala/sbt/librarymanagement/CrossVersion.scala new file mode 100644 index 00000000..c93702de --- /dev/null +++ b/core/src/main/scala/sbt/librarymanagement/CrossVersion.scala @@ -0,0 +1,330 @@ +/** + * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. + */ +package sbt.librarymanagement + +import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } + +/** Configures how a module will be cross-versioned. */ +abstract class CrossVersion() extends Serializable { + override def equals(o: Any): Boolean = o match { + case _: CrossVersion => true + case _ => false + } + override def hashCode: Int = { + 37 * (17 + "sbt.librarymanagement.CrossVersion".##) + } + override def toString: String = { + "CrossVersion()" + } +} +object CrossVersion extends sbt.librarymanagement.CrossVersionFunctions {} + +/** Disables cross versioning for a module. */ +sealed class Disabled private () extends sbt.librarymanagement.CrossVersion() with Serializable { + + override def equals(o: Any): Boolean = o match { + case _: Disabled => true + case _ => false + } + override def hashCode: Int = { + 37 * (17 + "sbt.librarymanagement.Disabled".##) + } + override def toString: String = { + "Disabled()" + } + private[this] def copy(): Disabled = { + new Disabled() + } + +} +object Disabled extends sbt.librarymanagement.Disabled { + def apply(): Disabled = new Disabled() +} + +/** + * Cross-versions a module using the result of + * prepending `prefix` and appending `suffix` to the binary version. + * For example, if `prefix = "foo_"` and `suffix = "_bar"` and the binary version is "2.10", + * the module is cross-versioned with "foo_2.10_bar". + */ +final class Binary private (val prefix: String, val suffix: String) + extends sbt.librarymanagement.CrossVersion() + with Serializable { + + private def this() = this("", "") + + override def equals(o: Any): Boolean = o match { + case x: Binary => (this.prefix == x.prefix) && (this.suffix == x.suffix) + case _ => false + } + override def hashCode: Int = { + 37 * (37 * (37 * (17 + "sbt.librarymanagement.Binary".##) + prefix.##) + suffix.##) + } + override def toString: String = { + "Binary(" + prefix + ", " + suffix + ")" + } + private[this] def copy(prefix: String = prefix, suffix: String = suffix): Binary = { + new Binary(prefix, suffix) + } + def withPrefix(prefix: String): Binary = { + copy(prefix = prefix) + } + def withSuffix(suffix: String): Binary = { + copy(suffix = suffix) + } +} +object Binary { + + def apply(): Binary = new Binary() + def apply(prefix: String, suffix: String): Binary = new Binary(prefix, suffix) +} + +/** Cross-versions a module using the string `value`. */ +final class Constant private (val value: String) + extends sbt.librarymanagement.CrossVersion() + with Serializable { + + private def this() = this("") + + override def equals(o: Any): Boolean = o match { + case x: Constant => (this.value == x.value) + case _ => false + } + override def hashCode: Int = { + 37 * (37 * (17 + "sbt.librarymanagement.Constant".##) + value.##) + } + override def toString: String = { + "Constant(" + value + ")" + } + private[this] def copy(value: String = value): Constant = { + new Constant(value) + } + def withValue(value: String): Constant = { + copy(value = value) + } +} +object Constant { + def apply(): Constant = new Constant() + def apply(value: String): Constant = new Constant(value) +} + +/** + * Cross-versions a module by stripping off -bin-suffix. + * This is intended for patch-version compatible alternative replacements. + */ +final class Patch private () extends sbt.librarymanagement.CrossVersion() with Serializable { + + override def equals(o: Any): Boolean = o match { + case _: Patch => true + case _ => false + } + override def hashCode: Int = { + 37 * (17 + "sbt.librarymanagement.Patch".##) + } + override def toString: String = { + "Patch()" + } + private[this] def copy(): Patch = { + new Patch() + } +} + +object Patch { + def apply(): Patch = new Patch() +} + +/** + * Cross-versions a module with the result of + * prepending `prefix` and appending `suffix` to the full version. + * For example, if `prefix = "foo_"` and `suffix = "_bar"` and the full version is "2.12.1", + * the module is cross-versioned with "foo_2.12.1_bar". + */ +final class Full private (val prefix: String, val suffix: String) + extends sbt.librarymanagement.CrossVersion() + with Serializable { + + private def this() = this("", "") + + override def equals(o: Any): Boolean = o match { + case x: Full => (this.prefix == x.prefix) && (this.suffix == x.suffix) + case _ => false + } + override def hashCode: Int = { + 37 * (37 * (37 * (17 + "sbt.librarymanagement.Full".##) + prefix.##) + suffix.##) + } + override def toString: String = { + "Full(" + prefix + ", " + suffix + ")" + } + private[this] def copy(prefix: String = prefix, suffix: String = suffix): Full = { + new Full(prefix, suffix) + } + def withPrefix(prefix: String): Full = { + copy(prefix = prefix) + } + def withSuffix(suffix: String): Full = { + copy(suffix = suffix) + } +} + +object Full { + def apply(): Full = new Full() + def apply(prefix: String, suffix: String): Full = new Full(prefix, suffix) +} + +trait DisabledFormats { self: sjsonnew.BasicJsonProtocol => + implicit lazy val DisabledFormat: JsonFormat[sbt.librarymanagement.Disabled] = + new JsonFormat[sbt.librarymanagement.Disabled] { + override def read[J](jsOpt: Option[J], + unbuilder: Unbuilder[J]): sbt.librarymanagement.Disabled = { + jsOpt match { + case Some(js) => + unbuilder.beginObject(js) + + unbuilder.endObject() + sbt.librarymanagement.Disabled() + case None => + deserializationError("Expected JsObject but found None") + } + } + override def write[J](obj: sbt.librarymanagement.Disabled, builder: Builder[J]): Unit = { + builder.beginObject() + + builder.endObject() + } + } + + implicit lazy val DisabledObjectFormat: JsonFormat[sbt.librarymanagement.Disabled.type] = + new JsonFormat[sbt.librarymanagement.Disabled.type] { + override def read[J](jsOpt: Option[J], + unbuilder: Unbuilder[J]): sbt.librarymanagement.Disabled.type = { + jsOpt match { + case Some(js) => + unbuilder.beginObject(js) + + unbuilder.endObject() + sbt.librarymanagement.Disabled + case None => + deserializationError("Expected JsObject but found None") + } + } + override def write[J](obj: sbt.librarymanagement.Disabled.type, builder: Builder[J]): Unit = { + builder.beginObject() + + builder.endObject() + } + } +} + +trait BinaryFormats { self: sjsonnew.BasicJsonProtocol => + implicit lazy val BinaryFormat: JsonFormat[sbt.librarymanagement.Binary] = + new JsonFormat[sbt.librarymanagement.Binary] { + override def read[J](jsOpt: Option[J], + unbuilder: Unbuilder[J]): sbt.librarymanagement.Binary = { + jsOpt match { + case Some(js) => + unbuilder.beginObject(js) + val prefix = unbuilder.readField[String]("prefix") + val suffix = unbuilder.readField[String]("suffix") + unbuilder.endObject() + sbt.librarymanagement.Binary(prefix, suffix) + case None => + deserializationError("Expected JsObject but found None") + } + } + override def write[J](obj: sbt.librarymanagement.Binary, builder: Builder[J]): Unit = { + builder.beginObject() + builder.addField("prefix", obj.prefix) + builder.addField("suffix", obj.suffix) + builder.endObject() + } + } +} + +trait ConstantFormats { self: sjsonnew.BasicJsonProtocol => + implicit lazy val ConstantFormat: JsonFormat[sbt.librarymanagement.Constant] = + new JsonFormat[sbt.librarymanagement.Constant] { + override def read[J](jsOpt: Option[J], + unbuilder: Unbuilder[J]): sbt.librarymanagement.Constant = { + jsOpt match { + case Some(js) => + unbuilder.beginObject(js) + val value = unbuilder.readField[String]("value") + unbuilder.endObject() + sbt.librarymanagement.Constant(value) + case None => + deserializationError("Expected JsObject but found None") + } + } + override def write[J](obj: sbt.librarymanagement.Constant, builder: Builder[J]): Unit = { + builder.beginObject() + builder.addField("value", obj.value) + builder.endObject() + } + } +} + +trait PatchFormats { self: sjsonnew.BasicJsonProtocol => + implicit lazy val PatchFormat: JsonFormat[sbt.librarymanagement.Patch] = + new JsonFormat[sbt.librarymanagement.Patch] { + override def read[J](jsOpt: Option[J], + unbuilder: Unbuilder[J]): sbt.librarymanagement.Patch = { + jsOpt match { + case Some(js) => + unbuilder.beginObject(js) + + unbuilder.endObject() + sbt.librarymanagement.Patch() + case None => + deserializationError("Expected JsObject but found None") + } + } + override def write[J](obj: sbt.librarymanagement.Patch, builder: Builder[J]): Unit = { + builder.beginObject() + + builder.endObject() + } + } +} + +trait FullFormats { self: sjsonnew.BasicJsonProtocol => + implicit lazy val FullFormat: JsonFormat[sbt.librarymanagement.Full] = + new JsonFormat[sbt.librarymanagement.Full] { + override def read[J](jsOpt: Option[J], + unbuilder: Unbuilder[J]): sbt.librarymanagement.Full = { + jsOpt match { + case Some(js) => + unbuilder.beginObject(js) + val prefix = unbuilder.readField[String]("prefix") + val suffix = unbuilder.readField[String]("suffix") + unbuilder.endObject() + sbt.librarymanagement.Full(prefix, suffix) + case None => + deserializationError("Expected JsObject but found None") + } + } + override def write[J](obj: sbt.librarymanagement.Full, builder: Builder[J]): Unit = { + builder.beginObject() + builder.addField("prefix", obj.prefix) + builder.addField("suffix", obj.suffix) + builder.endObject() + } + } +} + +trait CrossVersionFormats { + self: sjsonnew.BasicJsonProtocol + with sbt.librarymanagement.DisabledFormats + with sbt.librarymanagement.BinaryFormats + with sbt.librarymanagement.ConstantFormats + with sbt.librarymanagement.PatchFormats + with sbt.librarymanagement.FullFormats => + implicit lazy val CrossVersionFormat: JsonFormat[sbt.librarymanagement.CrossVersion] = + flatUnionFormat6[sbt.librarymanagement.CrossVersion, + sbt.librarymanagement.Disabled, + sbt.librarymanagement.Disabled.type, + sbt.librarymanagement.Binary, + sbt.librarymanagement.Constant, + sbt.librarymanagement.Patch, + sbt.librarymanagement.Full]("type") +} diff --git a/project/DatatypeConfig.scala b/project/DatatypeConfig.scala index 3e729cd4..774f77ee 100644 --- a/project/DatatypeConfig.scala +++ b/project/DatatypeConfig.scala @@ -42,6 +42,16 @@ object DatatypeConfig { "sbt.internal.librarymanagement.formats.LogicalClockFormats" :: Nil } + case "sbt.librarymanagement.CrossVersion" => { _ => + "sbt.librarymanagement.CrossVersionFormats" :: + "sbt.librarymanagement.DisabledFormats" :: + "sbt.librarymanagement.BinaryFormats" :: + "sbt.librarymanagement.ConstantFormats" :: + "sbt.librarymanagement.PatchFormats" :: + "sbt.librarymanagement.FullFormats" :: + Nil + } + // TODO: These are handled by BasicJsonProtocol, and sbt-datatype should handle them by default, imo case "Option" | "Set" | "scala.Vector" => { tpe => getFormats(oneArg(tpe))