Skip to content

Releases: ZacSweers/MoshiX

0.16.3

11 Jan 16:38
0836033
Compare
Choose a tag to compare

Fix: Build new type parameters when generating classes in moshi-ir rather than incorrectly reuse the original class's parameters. Resolves this issue (that was originally believed to be a Compose issue).

0.16.2

06 Jan 20:49
Compare
Choose a tag to compare
  • Fix: Pass generateProguardRules Gradle plugin option correctly.
  • Fix: Best-effort avoid synchronization race with IntelliJ openapi when registering proguard rule gen extension

0.16.1

06 Jan 20:49
Compare
Choose a tag to compare
  • moshi-ir now supports dynamic generation of proguard rules, bringing it to feature parity with Moshi's existing
    code gen.
    • Note that if you have any issues, this can be disabled via the Gradle extension's generateProguardRules
      property and using the manual rules mentioned in version 0.16.0's notes.
      moshi {
        generateProguardRules.set(false)
      }
  • New: To help with debugging moshi-ir, a new debug property is available in the Gradle extension. It is off
    by default and can be enabled like below. Please try this out and include its output when reporting issues. Thanks!
    moshi {
      debug.set(true)
    }

0.16.0

06 Jan 20:49
Compare
Choose a tag to compare

New: moshi-ir

An experimental Kotlin IR implementation of Moshi code gen and moshi-sealed code gen.

The goal of this is to have functional parity with their native Kapt/KSP code gen analogues but run as a fully
embedded IR plugin.

Benefits

  • Significantly faster build times.
    • No extra Kapt or KSP tasks, no extra source files to compile. This runs directly in kotlinc and generates IR that is
      lowered directly into bytecode.
  • No reflection required at runtime to support default parameter values.
  • Feature parity with Moshi's native code gen.
  • More detailed error messages for unexpected null values and missing properties. Now all errors are accumulated and
    reported at the end, rather than failing eagerly with just the first one encountered.

Cons

  • No support for Proguard file generation for now #193. You will
    need to add this manually to your rules if you use R8/Proguard.
    • One option is to use IR in debug builds and Kapt/KSP in release builds, the latter of which do still generate
      proguard rules.
    # Keep names for JsonClass-annotated classes
    -keepnames @com.squareup.moshi.JsonClass class **
    
    # Keep generated adapter classes' constructors
    -keepclassmembers class *JsonAdapter {
        public <init>(...);
    }
    
  • Kotlin IR is not a stable API and may change in future Kotlin versions. While I'll try to publish quickly to adjust to
    these, you should be aware. If you have any issues, you can always fall back to Kapt/KSP.

Installation

Simply apply the Gradle plugin in your project to use it. You can enable moshi-sealed code gen via the moshi
extension.

The Gradle plugin is published to Maven Central, so ensure you have mavenCentral() visible to your buildscript
classpath.

Maven Central

plugins {
  kotlin("jvm")
  id("dev.zacsweers.moshix") version "x.y.z"
}

moshi {
  // Opt-in to enable moshi-sealed, disabled by default.
  enableSealed.set(true)
}

Other

  • Update to Kotlin 1.6.10
  • Update to KSP 1.6.10-1.0.2

0.15.0

10 Dec 05:56
8e2e0cd
Compare
Choose a tag to compare
  • Update to Moshi 1.13.0
  • Removed: The moshi-ksp artifact has been upstreamed to Moshi itself as is no longer published.
  • Removed: The moshi-records-reflect artifact has been upstreamed to Moshi itself as is no longer published.
  • Update to Kotlin 1.6.0
  • Update to KotlinPoet 1.10.2

0.14.1

21 Sep 19:45
9da68f9
Compare
Choose a tag to compare
  • Build against JDK 17.
    • This means that moshi-sealed-java-sealed-reflect's support of sealed classes in Java is now out of preview and requires Java 17 to use.
    • moshi-records-reflect still targets Java 16 for maximum compatibility.
    • All other artifacts still target Java 8.
  • Update Kotlin to 1.5.31
  • Update KotlinPoet to 1.10.1

0.14.0

07 Sep 21:42
a147915
Compare
Choose a tag to compare
  • Update KSP to 1.5.30-1.0.0 stable!
  • moshi-sealed-ksp has now been merged into moshi-sealed-codegen. This artifact can be used for both kapt and
    ksp.
  • moshi-ksp is now soft-deprecated and will be fully deprecated once Moshi's next release is out with formal support.

0.13.0

27 Aug 14:59
Compare
Choose a tag to compare
  • Update Kotlin to 1.5.30.
  • Update KSP to 1.5.30-1.0.0-beta08.
  • Enhancement: RecordsJsonAdapterFactory is now aligned with the upstreamed implementation on Moshi itself.
    • Note that this is now soft-deprecated and will be fully deprecated once Moshi's next release is out with formal support.
    • This includes using a few more modern language APIs like MethodHandle and better unpacking of different runtime exceptions. Full details can be found in the PR.
  • Fix: Avoid implicitly converting elements to KotlinPoet in CodeBlocks to avoid noisy logging.
  • Fix: Improve self-referencing type variables parsing in moshi-ksp (see #125 and #151).

Special thanks to @yigit for contributing to this release!

0.12.2

21 Aug 02:55
c23e958
Compare
Choose a tag to compare
  • Fix: RecordsJsonAdapterFactory now properly respects @JsonQualifier annotations on components.
  • Fix: RecordsJsonAdapterFactory now supports non-public constructors (i.e. package or file-private).
  • Fix: Crash in moshi-ksp when dealing with generic typealias properties.

0.12.1

19 Aug 20:57
c66ddb5
Compare
Choose a tag to compare
  • Update to KSP 1.5.21-1.0.0-beta07.
  • Fix: Previously if you had a @JsonClass-annotated Java file with a custom generator, moshi-ksp would error
    out anyway due to it not being a Kotlin class. This is now fixed and it will safely ignore these files.
  • Fix: Generate missing @OptIn(ExperimentalStdLibApi::class) annotations in moshi-sealed when object
    adapters are used, as we use Moshi's reified addAdapter extension.

Thanks to @gabrielittner for contributing to this release!