From e6d996479bfee456d1a2ab24a36ff8d37a0550d3 Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Thu, 2 Nov 2023 17:23:07 -0700 Subject: [PATCH] build: add a few proguard rules [1/3] - Introduce a new directory for some specific proguard rules. kotlin.flags: - Remove DebugMetadata - Don't warn about missing non-runtime annotations Test: build AOSP & test on internal Bug: 309023911 Change-Id: Iee740b61a2afeba3482ff4e1f8213bd4cf46174a --- core/proguard.flags | 1 + core/proguard/kotlin.flags | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 core/proguard/kotlin.flags diff --git a/core/proguard.flags b/core/proguard.flags index 6dbee84c1d..9cbba0f317 100644 --- a/core/proguard.flags +++ b/core/proguard.flags @@ -61,3 +61,4 @@ } -include proguard_basic_keeps.flags +-include proguard/kotlin.flags diff --git a/core/proguard/kotlin.flags b/core/proguard/kotlin.flags new file mode 100644 index 0000000000..70dbaa7e81 --- /dev/null +++ b/core/proguard/kotlin.flags @@ -0,0 +1,19 @@ +# Ignore missing Kotlin meta-annotations so that Java-only projects can depend +# on projects that happen to be written in Kotlin but do not have a run-time +# dependency on the Kotlin standard library. Note these annotations are RUNTIME +# retention, but we won't need them available in Java-only projects. +-dontwarn kotlin.Metadata +-dontwarn kotlin.annotation.AnnotationRetention +-dontwarn kotlin.annotation.AnnotationTarget +-dontwarn kotlin.annotation.Retention +-dontwarn kotlin.annotation.Target + +# Kotlin DebugMetadata has no value in release builds, these two rules, will +# allow AppReduce to strip out DebutMetadata. +-checkdiscard interface kotlin.coroutines.jvm.internal.DebugMetadata +-assumenosideeffects class kotlin.coroutines.jvm.internal.DebugMetadataKt { + *** getDebugMetadataAnnotation(...); +} +-assumevalues class kotlin.coroutines.jvm.internal.DebugMetadataKt { + *** getDebugMetadataAnnotation(...) return null; +}