diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/ProguardSettings.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/ProguardSettings.kt index a3459d40d5c..1435033dcb3 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/ProguardSettings.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/ProguardSettings.kt @@ -24,4 +24,5 @@ abstract class ProguardSettings @Inject constructor( val obfuscate: Property = objects.notNullProperty(false) val optimize: Property = objects.notNullProperty(true) val joinOutputJars: Property = objects.notNullProperty(false) + val minimizeKotlinStandardLibrary: Property = objects.notNullProperty(false) } diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt index d53ad3dd621..722f548b18a 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt @@ -267,6 +267,7 @@ private fun JvmApplicationContext.configureProguardTask( dontoptimize.set(settings.optimize.map { !it }) joinOutputJars.set(settings.joinOutputJars) + minimizeKotlinStandardLibrary.set(settings.minimizeKotlinStandardLibrary) dependsOn(unpackDefaultResources) defaultComposeRulesFile.set(unpackDefaultResources.flatMap { it.resources.defaultComposeProguardRules }) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractProguardTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractProguardTask.kt index fa04502a912..bb5cffafcb8 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractProguardTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractProguardTask.kt @@ -42,6 +42,10 @@ abstract class AbstractProguardTask : AbstractComposeDesktopTask() { @get:Input val dontoptimize: Property = objects.nullableProperty() + @get:Optional + @get:Input + val minimizeKotlinStandardLibrary: Property = objects.nullableProperty() + @get:Optional @get:Input val joinOutputJars: Property = objects.nullableProperty() @@ -125,6 +129,10 @@ abstract class AbstractProguardTask : AbstractComposeDesktopTask() { writer.writeLn("-dontoptimize") } + if (minimizeKotlinStandardLibrary.orNull == false) { + writer.writeLn("-keep class kotlin.** { *; }") + } + writer.writeLn(""" -keep public class ${mainClass.get()} { public static void main(java.lang.String[]); diff --git a/gradle-plugins/compose/src/main/resources/default-compose-desktop-rules.pro b/gradle-plugins/compose/src/main/resources/default-compose-desktop-rules.pro index 89455d78d32..8f29c99b0b8 100644 --- a/gradle-plugins/compose/src/main/resources/default-compose-desktop-rules.pro +++ b/gradle-plugins/compose/src/main/resources/default-compose-desktop-rules.pro @@ -1,4 +1,3 @@ --keep class kotlin.** { *; } -keep class org.jetbrains.skia.** { *; } -keep class org.jetbrains.skiko.** { *; } diff --git a/tutorials/Native_distributions_and_local_execution/README.md b/tutorials/Native_distributions_and_local_execution/README.md index ffc91c4904d..4bed00b4532 100755 --- a/tutorials/Native_distributions_and_local_execution/README.md +++ b/tutorials/Native_distributions_and_local_execution/README.md @@ -663,3 +663,16 @@ compose.desktop { } } ``` + +Minimizing the Kotlin library is disabled by default. +To minimize it, +set the following property via Gradle DSL: +``` +compose.desktop { + application { + buildTypes.release.proguard { + minimizeKotlinStandardLibrary.set(true) + } + } +} +``` \ No newline at end of file