mirror of
https://github.com/fankes/moshi.git
synced 2025-10-18 07:29:22 +08:00
Enhance Proguard rules to preserve enum methods and improve annotation retention
This commit is contained in:
@@ -62,9 +62,23 @@ public data class ProguardConfig(
|
||||
if (!dontKeepClassNames)
|
||||
appendLine("-keepnames class $targetName")
|
||||
|
||||
// Keep the `JsonClass` annotation on the target class, R8 will shrink it away otherwise.
|
||||
// Keep the `JsonClass` annotation on the target class, R8 will strip it away otherwise.
|
||||
appendLine("-keep${if (dontKeepClassNames) ",allowobfuscation" else ""} @com.squareup.moshi.JsonClass class *")
|
||||
|
||||
//
|
||||
// -keepclassmembers enum * {
|
||||
// public static **[] values();
|
||||
// public static ** valueOf(java.lang.String);
|
||||
// public static <fields>;
|
||||
// }
|
||||
//
|
||||
// Keep the enum values method, R8 will strip it away otherwise.
|
||||
appendLine("-keepclassmembers enum * {")
|
||||
appendLine(" public static **[] values();")
|
||||
appendLine(" public static ** valueOf(java.lang.String);")
|
||||
appendLine(" public static <fields>;")
|
||||
appendLine("}")
|
||||
|
||||
appendLine("-if class $targetName")
|
||||
appendLine("-${if (dontKeepClassNames) "keepclassmembers" else "keep"} class $adapterCanonicalName {")
|
||||
// Keep the constructor for Moshi's reflective lookup
|
||||
|
Reference in New Issue
Block a user