mirror of
https://github.com/fankes/moshi.git
synced 2025-10-18 23:49:21 +08:00
Merge pull request #1211 from ZacSweers/z/appendLnFixes
Switch to new appendLine APIs
This commit is contained in:
@@ -49,27 +49,27 @@ internal data class ProguardConfig(
|
||||
val targetName = targetClass.reflectionName()
|
||||
val adapterCanonicalName = ClassName(targetClass.packageName, adapterName).canonicalName
|
||||
// Keep the class name for Moshi's reflective lookup based on it
|
||||
appendln("-if class $targetName")
|
||||
appendln("-keepnames class $targetName")
|
||||
appendLine("-if class $targetName")
|
||||
appendLine("-keepnames class $targetName")
|
||||
|
||||
appendln("-if class $targetName")
|
||||
appendln("-keep class $adapterCanonicalName {")
|
||||
appendLine("-if class $targetName")
|
||||
appendLine("-keep class $adapterCanonicalName {")
|
||||
// Keep the constructor for Moshi's reflective lookup
|
||||
val constructorArgs = adapterConstructorParams.joinToString(",")
|
||||
appendln(" public <init>($constructorArgs);")
|
||||
appendLine(" public <init>($constructorArgs);")
|
||||
// Keep any qualifier properties
|
||||
for (qualifierProperty in qualifierProperties) {
|
||||
appendln(" private com.squareup.moshi.JsonAdapter ${qualifierProperty.name};")
|
||||
appendLine(" private com.squareup.moshi.JsonAdapter ${qualifierProperty.name};")
|
||||
}
|
||||
appendln("}")
|
||||
appendLine("}")
|
||||
|
||||
qualifierProperties.asSequence()
|
||||
.flatMap { it.qualifiers.asSequence() }
|
||||
.map(ClassName::reflectionName)
|
||||
.sorted()
|
||||
.forEach { qualifier ->
|
||||
appendln("-if class $targetName")
|
||||
appendln("-keep @interface $qualifier")
|
||||
appendLine("-if class $targetName")
|
||||
appendLine("-keep @interface $qualifier")
|
||||
}
|
||||
|
||||
if (targetConstructorHasDefaults) {
|
||||
@@ -80,10 +80,10 @@ internal data class ProguardConfig(
|
||||
// synthetic <init>(...);
|
||||
// }
|
||||
//
|
||||
appendln("-if class $targetName")
|
||||
appendln("-keepnames class kotlin.jvm.internal.DefaultConstructorMarker")
|
||||
appendln("-if class $targetName")
|
||||
appendln("-keepclassmembers class $targetName {")
|
||||
appendLine("-if class $targetName")
|
||||
appendLine("-keepnames class kotlin.jvm.internal.DefaultConstructorMarker")
|
||||
appendLine("-if class $targetName")
|
||||
appendLine("-keepclassmembers class $targetName {")
|
||||
val allParams = targetConstructorParams.toMutableList()
|
||||
val maskCount = if (targetConstructorParams.isEmpty()) {
|
||||
0
|
||||
@@ -95,8 +95,8 @@ internal data class ProguardConfig(
|
||||
}
|
||||
allParams += "kotlin.jvm.internal.DefaultConstructorMarker"
|
||||
val params = allParams.joinToString(",")
|
||||
appendln(" public synthetic <init>($params);")
|
||||
appendln("}")
|
||||
appendLine(" public synthetic <init>($params);")
|
||||
appendLine("}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user