kosi-libs / Kodein

Painless Kotlin Dependency Injection

Home Page:https://kosi-libs.org/kodein

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Document Proguard Rules for JVM

mikedawson opened this issue · comments

Hi,

I'm using Compose Desktop as part of my multiplatform app (currently using KodeIN DI for Android, Desktop/JVM, Server/JVM, and JS).

The proguard rules for Android as per https://kosi-libs.org/kodein/7.21/framework/android.html#_proguard_configuration need an addition for JVM to keep the generic type info in supertype (in addition to the rules used on Android):

-keepattributes Signature

Proguard decreased the size of our distributable by around 50% (that's including the JVM distributable, so it probably decreased JAR size by around 75%).

Can this be added to the documentation? Maybe in the JVM section? https://kosi-libs.org/kodein/7.21/core/install.html#install-jvm. JVM doesn't have automatic rule consumption like Android, so having this in the docs becomes that much more important.

Thanks!

What does the rule -keepattributes Signature? 🤔
There is no Signature type in Kodein and its dependencies.

KodeIn uses the superclass trick to get type info that would otherwise be erased. Without -keepattributes Signature proguard will remove the type information from the type class, which will then cause the type token to fail. Signature doesn't refer to a type or class. It tells Proguard to keep all signatures as per https://www.guardsquare.com/manual/configuration/attributes