From 171e2442a6eb2c7e481c6d4976880b6a10e5b8fd Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Sun, 4 Dec 2022 20:06:51 -0500 Subject: [PATCH] Prepare for release 0.20.0. --- CHANGELOG.md | 47 +++++++++++++++++++ gradle.properties | 2 +- .../moshi-gradle-plugin/gradle.properties | 2 +- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d41a56f1..cd12212b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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() { + private val delegate = moshi.adapter() + 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 -------------- diff --git a/gradle.properties b/gradle.properties index cb308ad6..b7ce6018 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/moshi-ir/moshi-gradle-plugin/gradle.properties b/moshi-ir/moshi-gradle-plugin/gradle.properties index 2ef031a8..f09aeb4f 100644 --- a/moshi-ir/moshi-gradle-plugin/gradle.properties +++ b/moshi-ir/moshi-gradle-plugin/gradle.properties @@ -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/