From 994ef633cbad0807f88002885d632781a48cbe21 Mon Sep 17 00:00:00 2001 From: denis0001-dev Date: Fri, 16 Oct 2026 15:18:04 +0300 Subject: [PATCH] Fix ProGuard release build on the Java 25 toolchain The Compose plugin defaults to ProGuard 7.8.0, which cannot process the Java 25 class files produced by jvmToolchain(25): it fails to load the JDK itself and aborts with thousands of "can't find referenced class java.lang.Class" / "the configuration refers to the unknown class 'java.lang.String'" warnings, ending in "Please correct the above warnings first". Every release build has been failing there since the toolchain bump. Pin ProGuard 7.10.0 (7.9.0 added Java 25 support; 7.10.0 is the first release that also understands the Kotlin 2.4 metadata this project compiles against). Also ignore JOGL's JavaFX bridge. JetBrains Runtime ships jogl.all.jmod in its jmods directory, which ProGuard loads as a library jar; its classes extend program-side JavaFX classes, so JBR-based (macOS) builds fail with "7 instances of library classes depending on program classes". Temurin JDKs ship no such jmod, so that part is macOS/JBR-only. Verified locally: :app:desktop:exportReleaseProguardForCi succeeds and exports app/desktop/build/ci/proguard/. --- app/desktop/build.gradle.kts | 13 +++++++++++++ app/desktop/proguard-rules.pro | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/app/desktop/build.gradle.kts b/app/desktop/build.gradle.kts index 4472c32..a625092 100644 --- a/app/desktop/build.gradle.kts +++ b/app/desktop/build.gradle.kts @@ -240,6 +240,18 @@ fun stageWindowsJpackageRuntime(appImageRoot: File) { /** Desktop compile target — must stay in sync with `kotlin { jvmToolchain(desktopJvmTarget) }`. */ private val desktopJvmTarget = 25 +/** + * ProGuard version used by the Compose release tasks. + * + * The Compose plugin defaults to 7.8.0, which cannot process the Java 25 class files + * produced by `jvmToolchain(desktopJvmTarget)` — ProGuard then fails to load the JDK + * itself and reports `can't find referenced class java.lang.Class` / + * `the configuration refers to the unknown class 'java.lang.String'`. + * 7.9.0 added Java 25 support; 7.10.0 is the first release that also understands the + * Kotlin 2.4 metadata this project compiles against. + */ +private val proguardVersion = "7.10.0" + fun resolvePackagingJdkHome(): String { // The desktop module compiles to jvmToolchain(desktopJvmTarget) classes; jpackage must // bundle a runtime >= that or the installed app dies at launch with @@ -378,6 +390,7 @@ compose.desktop { javaHome = resolvePackagingJdkHome() buildTypes.release.proguard { + version = proguardVersion configurationFiles.from(project.file("proguard-rules.pro")) } diff --git a/app/desktop/proguard-rules.pro b/app/desktop/proguard-rules.pro index ba4dc04..c1c5911 100644 --- a/app/desktop/proguard-rules.pro +++ b/app/desktop/proguard-rules.pro @@ -39,3 +39,11 @@ ; (...); } + +# JetBrains Runtime bundles a `jogl.all.jmod` (JOGL, incl. its JavaFX bridge) in its jmods +# directory, which ProGuard picks up as a library jar. Those JOGL classes extend JavaFX +# classes that are ProGuard *program* inputs, so ProGuard reports 7x +# "library class com.jogamp.newt.javafx.* extends or implements program class javafx.*" +# and then aborts with "Please correct the above warnings first". The app never uses JOGL, +# so only that JavaFX bridge is ignored (JDKs without the jmod, e.g. Temurin, are unaffected). +-dontwarn com.jogamp.newt.javafx.**