diff --git a/CHANGELOG.md b/CHANGELOG.md index 7944f58f..45c50339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,69 @@ Changelog ========= +Version 0.16.0 +-------------- + +#### **New:** [moshi-ir](https://github.com/ZacSweers/MoshiX/tree/main/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. + - See https://github.com/square/moshi/issues/836 for more details! + +**Cons** +- No support for Proguard file generation for now [#193](https://github.com/ZacSweers/MoshiX/issues/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. + ```proguard + # Keep names for JsonClass-annotated classes + -keepnames class @com.squareup.moshi.JsonClass ** + + # Keep generated adapter classes' constructors + -keepclassmembers class *JsonAdapter { + public (...); + } + ``` +- 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](https://img.shields.io/maven-central/v/dev.zacsweers.moshix/moshi-gradle-plugin.svg)](https://mvnrepository.com/artifact/dev.zacsweers.moshix/moshi-gradle-plugin) +```gradle +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` + Version 0.15.0 -------------- diff --git a/README.md b/README.md index 524e11ab..0be80318 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ Extensions for [Moshi](https://github.com/square/moshi) -* [moshi-ir](https://github.com/ZacSweers/MoshiX/tree/main/moshi-ir) - A Kotlin IR implementation of Moshi code gen. +* [moshi-ir](https://github.com/ZacSweers/MoshiX/tree/main/moshi-ir) - A Kotlin IR implementation of Moshi and + moshi-sealed code gen! * [moshi-adapters](https://github.com/ZacSweers/MoshiX/tree/main/moshi-adapters) - A collection of custom adapters for Moshi. * [moshi-metadata-reflect](https://github.com/ZacSweers/MoshiX/tree/main/moshi-metadata-reflect) - A [kotlinx-metadata](https://github.com/JetBrains/kotlin/tree/master/libraries/kotlinx-metadata/jvm) based implementation of `KotlinJsonAdapterFactory`. This allows for reflective Moshi serialization on Kotlin classes without the cost of including kotlin-reflect. * [moshi-sealed](https://github.com/ZacSweers/MoshiX/tree/main/moshi-sealed) - Reflective and code gen implementations for serializing Kotlin sealed classes via Moshi polymorphic adapters. diff --git a/gradle.properties b/gradle.properties index badc72e7..378d54bc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,7 +24,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 \ --add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED GROUP=dev.zacsweers.moshix -VERSION_NAME=0.16.0-SNAPSHOT +VERSION_NAME=0.16.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/README.md b/moshi-ir/README.md index 87310daf..10152b65 100644 --- a/moshi-ir/README.md +++ b/moshi-ir/README.md @@ -8,8 +8,8 @@ embedded IR plugin. **Benefits** - Significantly faster build times. - - No 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 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 @@ -17,8 +17,8 @@ embedded IR plugin. - See https://github.com/square/moshi/issues/836 for more details! **Cons** -- No support for Proguard file generation for now. You will need to add this manually to your rules if you use - R8/Proguard. +- No support for Proguard file generation for now [#193](https://github.com/ZacSweers/MoshiX/issues/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. ```proguard diff --git a/moshi-ir/moshi-gradle-plugin/gradle.properties b/moshi-ir/moshi-gradle-plugin/gradle.properties index e5cf91fd..feeb495a 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.16.0-SNAPSHOT +VERSION_NAME=0.16.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/