MoshiX

Extensions for Moshi including IR plugins, moshi-sealed, and more.

APACHE-2.0 License

Stars
490

Bot releases are hidden (Show)

MoshiX - 0.27.0 Latest Release

Published by ZacSweers 5 months ago

Update to K2

This release updates to K2, aka Kotlin 2.0.0. This also builds against KSP 2.0.0-1.0.21.

  • [moshi-metadata-reflect] Update to stable kotlin metadata API that ships in K2. The new transitive dependency is now org.jetbrains.kotlin:kotlin-metadata-jvm:2.0.0.
  • [ksp] All KSP processors are tested against both KSP 1 and the in-beta KSP2.
  • [moshi-ir] Support K2 IR API changes. We may explore building out FIR support for better IDE support in the future, but for now the entire implementation remains in an IR-only plugin.

What's Changed

Full Changelog: https://github.com/ZacSweers/MoshiX/compare/0.26.0...0.27.0

MoshiX - 0.26.0

Published by ZacSweers 5 months ago

New: Publish a new moshi-immutable-adapters artifact with support for kotlinx.collections.immutable.

Gradle dependency

dependencies {
  implementation("dev.zacsweers.moshix:moshi-immutable-adapters:<version>")
}

In code

val moshi = Moshi.Builder().add(ImmutableCollectionsJsonAdapterFactory()).build()

Supported types

  • ImmutableCollection
  • ImmutableList
  • ImmutableSet
  • ImmutableMap
  • PersistentCollection
  • PersistentList
  • PersistentSet
  • PersistentMap

Misc

  • Omit the stdlib from transitive dependencies on the compiler plugin and Gradle plugin artifacts. Both kotlinc and Gradle impose their own versions on the classpath.
  • Update Moshi to 1.15.1.
  • Update kotlinx-metadata to 0.9.0.
  • Update KotlinPoet to 1.16.0.
  • Update Kotlin to 1.9.24.
  • Update KSP to 1.9.24-1.0.20.
  • Update Guava to 33.2.0-jre.
  • Compile against Gradle 8.7.

What's Changed

Full Changelog: https://github.com/ZacSweers/MoshiX/compare/0.25.1...0.26.0

MoshiX - 0.25.1

Published by ZacSweers 11 months ago

  • Update to Kotlin 1.9.21.
  • Update to KSP 1.9.20-1.0.14.
  • Update to KotlinPoet 1.15.1.

What's Changed

Full Changelog: https://github.com/ZacSweers/MoshiX/compare/0.25.0...0.25.1

MoshiX - 0.25.0

Published by ZacSweers 12 months ago

  • Update to Kotlin 1.9.20. moshi-ir now requires Kotlin 1.9.20.
  • Update to KSP 1.9.20-1.0.13.
  • Update to Guava 32.1.3-jre.
  • Build against Gradle 8.4.

What's Changed

Full Changelog: https://github.com/ZacSweers/MoshiX/compare/0.24.3...0.25.0

MoshiX - 0.24.3

Published by ZacSweers about 1 year ago

  • Fix: Enable KSP proguard rule gen again in moshi-ir. We accidentally encountered a bug in KSP and work around it now.

What's Changed

Full Changelog: https://github.com/ZacSweers/MoshiX/compare/0.24.2...0.24.3

MoshiX - 0.24.2

Published by ZacSweers about 1 year ago

  • Fix: Use correct platform-specific configuration for applying KSP dependency in moshi-ir.
  • Fix: Don't enable moshi-ir/ksp on non-JVM/Android platforms until they're supported upstream.

What's Changed

Full Changelog: https://github.com/ZacSweers/MoshiX/compare/0.24.1...0.24.2

MoshiX - 0.24.1

Published by ZacSweers about 1 year ago

  • 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: https://github.com/ZacSweers/MoshiX/compare/0.24.0...0.24.1

MoshiX - 0.24.0

Published by ZacSweers about 1 year ago

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: https://github.com/ZacSweers/MoshiX/compare/0.23.0...0.24.0

MoshiX -

Published by ZacSweers about 1 year ago

  • Fix: Write generated proguard rules to the correct resources path.
MoshiX - 0.24.0-RC

Published by ZacSweers over 1 year ago

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: https://github.com/ZacSweers/MoshiX/compare/0.23.0...0.24.0-RC

MoshiX - 0.23.0

Published by ZacSweers over 1 year ago

  • 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: https://github.com/ZacSweers/MoshiX/compare/0.22.1...0.23.0

MoshiX -

Published by ZacSweers over 1 year ago

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 **
MoshiX - 0.22.0

Published by ZacSweers over 1 year ago

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: https://github.com/ZacSweers/MoshiX/compare/0.21.0...0.22.0

MoshiX - 0.21.0

Published by ZacSweers almost 2 years ago

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: https://github.com/ZacSweers/MoshiX/compare/0.20.0...0.21.0

MoshiX - 0.20.0

Published by ZacSweers almost 2 years ago

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: https://github.com/ZacSweers/MoshiX/compare/0.19.0...0.20.0

MoshiX - 0.19.0

Published by ZacSweers about 2 years ago

  • 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: https://github.com/ZacSweers/MoshiX/compare/0.18.3...0.19.0

MoshiX - 0.18.3

Published by ZacSweers over 2 years ago

  • Fix: Support @Json.ignore in MetadataKotlinJsonAdapterFactory.

What's Changed

Full Changelog: https://github.com/ZacSweers/MoshiX/compare/0.18.2...0.18.3

MoshiX - 0.18.2

Published by ZacSweers over 2 years ago

Highlights

  • Fix: Incremental processing when sealed types are spread across multiple files now works
    correctly for KSP code gen in moshi-sealed. Thanks to @efemoney
  • Update KotlinPoet to 1.12.0
  • Update kotlinx-metadata to 0.5.0

What's Changed

Full Changelog: https://github.com/ZacSweers/MoshiX/compare/0.18.1...0.18.2

MoshiX -

Published by ZacSweers over 2 years ago

Add a missing proguard rule for @AdaptedBy annotations to ensure they're kept on classes that use
them. Unfortunately there doesn't appear to be a more granular way preserve these annotations without
also keeping the whole class.

MoshiX -

Published by ZacSweers over 2 years ago

  • Update to Kotlin 1.7.0 (Kotlin 1.6.x is no longer supported).
  • Remove remaining use of deprecated descriptor APIs in IR.
  • Update to KSP 1.7.0-1.0.6
Package Rankings
Top 15.43% on Repo1.maven.org