Merge pull request #1211 from ZacSweers/z/appendLnFixes

Switch to new appendLine APIs
This commit is contained in:
Jake Wharton
2020-09-01 09:17:38 -04:00
committed by GitHub

View File

@@ -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("}")
}
}
}