Skip to content

Commit

Permalink
Prepare for release 0.16.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Dec 24, 2021
1 parent 7650423 commit 80a1f3e
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 7 deletions.
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 <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](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
--------------

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions moshi-ir/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ 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
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. 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
Expand Down
2 changes: 1 addition & 1 deletion moshi-ir/moshi-gradle-plugin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down

0 comments on commit 80a1f3e

Please sign in to comment.