Update Proguard configuration for codegen (#542)

* Update Proguard configuration for codegen

-keepnames will prevent Proguard from renaming the class during obfuscation phase but won't protect the class from code shrinking.
In most cases, the generated are never referenced directly in the code as the adapters are loaded dynamically.
This means that, for Proguard, the class is unused and it will remove the generated adapters during the shrinking phase.

The adapters need to be kept as well as there primary constructor.

* Keep fields of generated JsonAdapter
This commit is contained in:
Pierre Degand
2018-05-16 03:34:56 +02:00
committed by Jesse Wilson
parent 16938ab83a
commit b5a50d8281

View File

@@ -597,7 +597,10 @@ Additional rules are needed if you are using Kotlin:
```
*...If you are using the codegen API (i.e. `JsonClass(generateAdapter = true)`):*
```
-keepnames class **JsonAdapter
-keep class **JsonAdapter {
<init>(...);
<fields>;
}
-keepnames @com.squareup.moshi.JsonClass class *
```