mirror of https://github.com/sbt/sbt.git
Merge pull request #296 from eed3si9n/wip/jsonformats
move CrossVersion to src/
This commit is contained in:
commit
0d9ff2b63e
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
||||
}
|
||||
|
|
@ -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")
|
||||
}
|
||||
|
|
@ -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()
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in New Issue