ZacSweers / MoshiX

Extensions for Moshi including IR plugins, moshi-sealed, and more.
Apache License 2.0
492 stars 37 forks source link

No Proguard/R8 rules generated by `moshi-sealed-codegen`? #554

Closed mhelder closed 4 months ago

mhelder commented 4 months ago

I initially thought I was hitting the same issue as described in https://github.com/ZacSweers/MoshiX/issues/415, but decided to open a new issue because I don't get an error. Instead, I cannot seem to find any generated Proguard/R8 rules, and my generated adapters get minified away.

Some context: one of our apps has several sealed classes that live inside a package name that resembles com.example.data.model for which we rely on generated adapters. The package declaration of the generated adapters ends up being:

package com.example.`data`.model

And we actually see the same for adapters generated by moshi-kotlin-codegen.

What seems to differ is that we don't see any generated Proguard/R8 rules for classes generated by moshi-sealed-codegen, yet we do for classes generated by moshi-kotlin-codegen. But maybe I'm not looking in the right place? All classes live in a library module. Inside build/intermediates/generated_proguard_file/proguard.txt I see the rules moshi-kotlin-codegen generated, but none for our sealed classes covered by moshi-sealed-codegen.

As a result, everything works well, until we turn on minification. Then we get runtime errors stating the adapters generated by moshi-sealed-codegen cannot be found.

How do I confirm if moshi-proguard-rule-gen gets applied correctly? Where should I be able to find the rules it generated? Just in case, I tried explicitly declaring moshi-proguard-rule-gen as ksp dependency, but no joy.

We're currently on moshi:1.15.0 and moshix:0.24.3. I also tested with latest versions for both, but did not seem to make a difference.