Skip to content

Commit

Permalink
add desktop proguard
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlaster committed Jan 9, 2025
1 parent d49e24c commit e600fb4
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
10 changes: 10 additions & 0 deletions desktopApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
}
}
}
}
}

Expand Down
80 changes: 80 additions & 0 deletions desktopApp/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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 <init>(); }

-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.** { *; }

0 comments on commit e600fb4

Please sign in to comment.