Skip to content

Commit

Permalink
Prepare for release 0.20.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Dec 5, 2022
1 parent adf5a11 commit 171e244
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
Changelog
=========

Version 0.20.0
--------------

_2022-12-04_

#### **New:** `@FallbackJsonAdapter`

moshi-sealed now supports a new `@FallbackJsonAdapter`. This is a proxy to Moshi's `PolymorphicJsonAdapter.withFallbackJsonAdapter()`. This allows you to specify a custom `JsonAdapter` to handle cases of unrecognized type labels in decoding. It's advanced usage and not recommended for regular cases.

The specified `JsonAdapter` must have a public constructor with no parameters or a single `Moshi` parameter.

```kotlin
@FallbackJsonAdapter(FrogFallbackJsonAdapter::class)
@JsonClass(generateAdapter = true, generator = "sealed:type")
sealed class Frog {

@JsonClass(generateAdapter = true)
@TypeLabel("original", null)
data class OriginalFrog(...)

@JsonClass(generateAdapter = true)
@TypeLabel("poisonous")
data class PoisonousFrog(...)

class FrogFallbackJsonAdapter(moshi: Moshi) : JsonAdapter<Frog>() {
private val delegate = moshi.adapter<OriginalFrog>()
override fun fromJson(reader: JsonReader): Frog? {
// Default to original frog
return delegate.fromJson(reader)
}

//...
}
}
```

#### Misc

* **Enhancement:** Generate extra proguard rules for `@NestedSealed` types to prevent R8 from inlining the parent sealed type into the subtype in some cases.
* **Enhancement:** Proguard generation in moshi-ir now uses [Anvil](https://github.com/square/anvil)'s more optimized compiler util APIs.
* **Enhancement:** Check and report more error cases in moshi-ir and moshi-sealed code gen.
* **Fix:** moshi-ir now properly generates proguard rules for moshi-sealed types.
* **Fix:** track `@NestedSealed` types as originating files in moshi-sealed KSP.
* **Enhancement:** Substantially improved KSP and IR test coverage of error cases.
* Update to Kotlin `1.7.22`.
* Update to KSP `1.7.22-1.0.8`.

Version 0.19.0
--------------

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8

GROUP=dev.zacsweers.moshix
VERSION_NAME=0.20.0-SNAPSHOT
VERSION_NAME=0.20.0
POM_DESCRIPTION=Moshi Extensions
POM_URL=https://github.com/ZacSweers/MoshiX
POM_SCM_URL=https://github.com/ZacSweers/MoshiX
Expand Down
2 changes: 1 addition & 1 deletion moshi-ir/moshi-gradle-plugin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ POM_ARTIFACT_ID=moshi-gradle-plugin
POM_PACKAGING=jar

GROUP=dev.zacsweers.moshix
VERSION_NAME=0.20.0-SNAPSHOT
VERSION_NAME=0.20.0
POM_DESCRIPTION=A Kotlin compiler plugin that generates Moshi JsonAdapter classes.
POM_URL=https://github.com/ZacSweers/MoshiX/
POM_SCM_URL=https://github.com/ZacSweers/MoshiX/
Expand Down

0 comments on commit 171e244

Please sign in to comment.