From e600fb4b5c35a41185a81c07a33cbcdc8d1487ee Mon Sep 17 00:00:00 2001 From: Tlaster Date: Sat, 4 Jan 2025 16:32:37 +0900 Subject: [PATCH] add desktop proguard --- desktopApp/build.gradle.kts | 10 +++++ desktopApp/proguard-rules.pro | 80 +++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 desktopApp/proguard-rules.pro diff --git a/desktopApp/build.gradle.kts b/desktopApp/build.gradle.kts index 5bc8c437a..80b8bd5b0 100644 --- a/desktopApp/build.gradle.kts +++ b/desktopApp/build.gradle.kts @@ -47,6 +47,16 @@ compose.desktop { packageName = "dev.dimension.flare" packageVersion = "1.0.0" } + buildTypes { + release { + proguard { + version.set("7.6.1") + this.configurationFiles.from( + file("proguard-rules.pro") + ) + } + } + } } } diff --git a/desktopApp/proguard-rules.pro b/desktopApp/proguard-rules.pro new file mode 100644 index 000000000..9e7ebd674 --- /dev/null +++ b/desktopApp/proguard-rules.pro @@ -0,0 +1,80 @@ +# OkHttp platform used only on JVM and when Conscrypt and other security providers are available. +-dontwarn okhttp3.internal.platform.** +-dontwarn org.conscrypt.** +-dontwarn org.bouncycastle.** +-dontwarn org.openjsse.** +-dontwarn androidx.compose.runtime.** + +-dontwarn org.slf4j.impl.StaticLoggerBinder + +-keep class app.bsky.** { *; } +-keep class de.jensklingenberg.ktorfit.** { *; } +-keepclassmembers class de.jensklingenberg.ktorfit.** { *; } + +-keep class com.sun.jna** { *; } +-keep enum com.sun.jna.** { *; } +-keep class com.jthemedetecor.** { *; } +-keep class oshi.** { *; } + +-keep class androidx.compose.runtime.SnapshotStateKt__DerivedStateKt { *; } # VerifyError + +-assumenosideeffects public class androidx.compose.runtime.ComposerKt { + void sourceInformation(androidx.compose.runtime.Composer,java.lang.String); + void sourceInformationMarkerStart(androidx.compose.runtime.Composer,int,java.lang.String); + void sourceInformationMarkerEnd(androidx.compose.runtime.Composer); + boolean isTraceInProgress(); + void traceEventStart(int, java.lang.String); + void traceEventEnd(); +} + +-keep class kotlinx.coroutines.internal.MainDispatcherFactory { *; } +-keep class kotlinx.coroutines.swing.SwingDispatcherFactory { *; } + +-dontwarn javax.annotation.** +-keep class * extends androidx.room.RoomDatabase { void (); } + +-keep @kotlinx.serialization.Serializable class * {*;} + +# Keep `Companion` object fields of serializable classes. +# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects. +-if @kotlinx.serialization.Serializable class ** +-keepclassmembers class <1> { + static <1>$Companion Companion; +} + +# Keep `serializer()` on companion objects (both default and named) of serializable classes. +-if @kotlinx.serialization.Serializable class ** { + static **$* *; +} +-keepclassmembers class <2>$<3> { + kotlinx.serialization.KSerializer serializer(...); +} + +# Keep `INSTANCE.serializer()` of serializable objects. +-if @kotlinx.serialization.Serializable class ** { + public static ** INSTANCE; +} +-keepclassmembers class <1> { + public static <1> INSTANCE; + kotlinx.serialization.KSerializer serializer(...); +} + +# @Serializable and @Polymorphic are used at runtime for polymorphic serialization. +-keepattributes RuntimeVisibleAnnotations,AnnotationDefault + +# Don't print notes about potential mistakes or omissions in the configuration for kotlinx-serialization classes +# See also https://github.com/Kotlin/kotlinx.serialization/issues/1900 +-dontnote kotlinx.serialization.** + +# Serialization core uses `java.lang.ClassValue` for caching inside these specified classes. +# If there is no `java.lang.ClassValue` (for example, in Android), then R8/ProGuard will print a warning. +# However, since in this case they will not be used, we can disable these warnings +-dontwarn kotlinx.serialization.internal.ClassValueReferences + +# disable optimisation for descriptor field because in some versions of ProGuard, optimization generates incorrect bytecode that causes a verification error +# see https://github.com/Kotlin/kotlinx.serialization/issues/2719 +-keepclassmembers public class **$$serializer { + private ** descriptor; +} + +-keep class com.mayakapps.compose.** { *; } \ No newline at end of file