Skip to content

Commit

Permalink
move CrossVersion to src/
Browse files Browse the repository at this point in the history
Fixes sbt/sbt#4595
Ref sbt#290
Ref sbt#280

This is bit of an odd one.

To keep bincompat and also to fix sbt 0.13 compatibility issue we have made `Disabled` companion object extend `Disabled` type.
This actually created a subtle deserialization issue:

```
[error] scala.MatchError: Disabled() (of class sbt.librarymanagement.Disabled$)
[error] 	at sjsonnew.FlatUnionFormats$$anon$5.write(FlatUnionFormats.scala:220)
[error] 	at sjsonnew.JsonWriter.addField(JsonFormat.scala:40)
[error] 	at sjsonnew.JsonWriter.addField$(JsonFormat.scala:37)
[error] 	at sjsonnew.FlatUnionFormats$$anon$5.addField(FlatUnionFormats.scala:208)
[error] 	at sjsonnew.Builder.addField(Builder.scala:43)
[error] 	at sbt.librarymanagement.ModuleIDFormats$$anon$1.write(ModuleIDFormats.scala:46)
```

This is because Contraband generates `flatUnionFormat5[CrossVersion, Disabled, ...]` for all of the subtypes of `CrossVersion`, which uses the runtime type information. Now that `Disabled` object is also in the mix, this created JSON that `CrossVersionFormats` cannot deserialize. This brings the code into src/ so we can write this part manually.
  • Loading branch information
eed3si9n committed Apr 2, 2019
1 parent f6c267a commit 2f8d9ad
Show file tree
Hide file tree
Showing 17 changed files with 343 additions and 408 deletions.
43 changes: 0 additions & 43 deletions core/src/main/contraband-scala/sbt/librarymanagement/Binary.scala

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

43 changes: 0 additions & 43 deletions core/src/main/contraband-scala/sbt/librarymanagement/Full.scala

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
33 changes: 0 additions & 33 deletions core/src/main/contraband-scala/sbt/librarymanagement/Patch.scala

This file was deleted.

This file was deleted.

Loading

0 comments on commit 2f8d9ad

Please sign in to comment.