Skip to content

Releases: ZacSweers/MoshiX

0.24.1

03 Sep 03:10
Compare
Choose a tag to compare
  • Fix: Use correct name for each KotlinCompilation's implementation configuration in KMP projects. Note that Moshi still only supports JVM/Android.
  • Update to Kotlin 1.9.10.
  • Update to KSP 1.9.10-1.0.13.
  • Compile against Gradle 8.3.
  • Remove shaded anvil-compiler-utils dependency from moshi-ir.

What's Changed

Full Changelog: 0.24.0...0.24.1

0.24.0

22 Jul 20:25
Compare
Choose a tag to compare

New: Move proguard rule generation to a standalone KSP processor.

This is necessary in order to support both K2 and avoid incremental compilation issues in Kotlin 1.9.x.

For moshi-sealed KSP users, there should be no changes necessary.

For moshi-ir users, you must now apply the KSP gradle plugin as well as the moshix plugin. MoshiX's gradle plugin does not directly declare a transitive dependency on the KSP plugin to avoid Gradle classloader conflicts.

plugins {
  // Other plugins
  id("dev.zacsweers.moshix") version "x.y.z"
+  id("com.google.devtools.ksp") version "x.y.z"
}

If you don't want this or don't need proguard rule generation, you can opt out by setting the moshix.generateProguardRules gradle property to false.

  • Update KSP to 1.9.0-1.0.12.
  • Update KotlinPoet to 1.14.2.
  • Update to kotlinx-metadata 0.7.0.
  • Update to Guava 32.1.1-jre.

What's Changed

New Contributors

Full Changelog: 0.23.0...0.24.0

0.24.0-RC2

20 Jul 16:58
Compare
Choose a tag to compare
0.24.0-RC2 Pre-release
Pre-release
  • Fix: Write generated proguard rules to the correct resources path.

0.24.0-RC

18 Jul 18:05
Compare
Choose a tag to compare
0.24.0-RC Pre-release
Pre-release

New: Move proguard rule generation to a standalone KSP processor.

This is necessary in order to support both K2 and avoid incremental compilation issues in Kotlin 1.9.x.

For moshi-sealed KSP users, there should be no changes necessary.

For moshi-ir users, you must now apply the KSP gradle plugin as well as the moshix plugin. MoshiX's gradle plugin does not directly declare a transitive dependency on the KSP plugin to avoid Gradle classloader conflicts.

plugins {
  // Other plugins
  id("dev.zacsweers.moshix") version "x.y.z"
+  id("com.google.devtools.ksp") version "x.y.z"
}

If you don't want this or don't need proguard rule generation, you can opt out by setting the moshix.generateProguardRules gradle property to false.

This first release is an RC release to ensure there are no issues with the new standalone processor. If you encounter any issues, please file them!

What's Changed

New Contributors

Full Changelog: 0.23.0...0.24.0-RC

0.23.0

06 Jul 21:41
Compare
Choose a tag to compare
  • Update to Kotlin 1.9.0. The moshi-ir plugin now requires 1.9.0.
  • Update kotlinx-metadata to 0.6.2.
  • Update shaded Anvil utils to 2.4.6.
  • Update Moshi to 1.15.0.
  • Update KSP to 1.9.0-1.0.11.

What's Changed

Full Changelog: 0.22.1...0.23.0

0.22.1

16 Apr 19:19
Compare
Choose a tag to compare

moshi-sealed
Keep signatures for typed annotated with @NestedSealed. This ensures that the annotation, itself isn't stripped from the use on the class.

This is done via this keep rule in moshi-sealed-runtime's embedded proguard rules, which should still allow strinking/optimization of the class itself.

-keepnames @dev.zacsweers.moshix.sealed.annotations.NestedSealed class **

0.22.0

03 Apr 13:19
Compare
Choose a tag to compare

Highlights

  • Update to Kotlin 1.8.20. Kotlin 1.8.20 or later is required for moshi-ir.
  • Update to KSP 1.8.20-1.0.10.
  • Update kotlinx-metadata-jvm to 0.6.0.
  • Fix: Don't use experimental-gated addAdapter with generated object adapters.

All Changes

New Contributors

Full Changelog: 0.21.0...0.22.0

0.21.0

29 Dec 05:04
Compare
Choose a tag to compare

2022-12-28

New: Update to Kotlin 1.8.0.

  • For moshi-ir, this release is only compatible with Kotlin 1.8 or later.
  • Migrate the IR and AnalysisHandlerExtension plugins to new CompilerPluginRegistrar entrypoint API.

New: Experimental support for the new K2 compiler in moshi-ir.

Note this comes with several caveats:

  • There is no FIR plugin in moshi-ir itself (not needed). This just marks itself as compatible with the new compiler and avoids using incompatible IR APIs.
  • This only works if proguard rule generation is disabled, as there is no support in FIR currently for generating files.
  • K2 compiler itself is extremely experimental.

In short, this is only really to unblock anyone doing their own testing of K2 and don't want this
plugin to disable it. If you see any issues, please file a bug here and disable K2 in your project
in the meantime.

Misc

  • Update JVM target to 11.
  • Update Anvil compiler-utils to 2.4.3.

What's Changed

Full Changelog: 0.20.0...0.21.0

0.20.0

05 Dec 01:34
Compare
Choose a tag to compare

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.

@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)
    }
    
    //...
  }
}

New: Experimental support for the new K2 compiler in moshi-ir.

Edit: this isn't usable in this release, don't try to use it!

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'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.

What's Changed

Full Changelog: 0.19.0...0.20.0

0.19.0

29 Sep 20:31
Compare
Choose a tag to compare
  • Update to Kotlin 1.7.20.
  • Update to KSP 1.7.20-1.0.6.

Note this release requires Kotlin 1.7.20 or newer.

What's Changed

Full Changelog: 0.18.3...0.19.0