I’ve configured Proguard to my liking based on the...
# compose-desktop
y
I’ve configured Proguard to my liking based on the documentation which creates a nice obfuscated
min.jar
. The problem is that native distribution packages don’t want to use the obfuscated jar to create .dmg, even when I’ve clearly specified the location.
Copy code
import com.netguru.extensions.desktopMain
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat

buildscript {
    dependencies {
        classpath(libs.desktop.proguard)
    }
}

plugins {
    kotlin("multiplatform")
    alias(libs.plugins.compose)
}

group = libs.versions.project.group.get()
version = libs.versions.project.version.get()

kotlin {
    jvm("desktop")
    sourceSets {
        desktopMain {
            dependencies {
                implementation(compose.desktop.currentOs)
                implementation(project(":application"))
            }
        }
    }
}

compose.desktop {
    application {
        mainClass = "MainKt"

        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = libs.versions.desktop.packageName.get()
            packageVersion = libs.versions.desktop.packageVersion.get()
        }
        disableDefaultConfiguration()
        from(kotlin.targets["desktop"])
        val file: File? =
            fileTree("build/compose/jars").files.firstOrNull { file: File -> file.name.contains(".min.jar") }
        mainJar.set(file)
    }
}
tasks.register("createDesktopPackage") {
    group = "desktop package"
    dependsOn("obfuscate")
    dependsOn("package")
}

tasks.register<proguard.gradle.ProGuardTask>("obfuscate") {
    val packageUberJarForCurrentOS by tasks.getting
    dependsOn(packageUberJarForCurrentOS)
    val files = packageUberJarForCurrentOS.outputs.files
    injars(files)
    outjars(files.map { file -> File(file.parentFile, "${file.nameWithoutExtension}.min.jar") })

    val library = if (System.getProperty("java.version").startsWith("1.")) "lib/rt.jar" else "jmods"
    libraryjars("${System.getProperty("java.home")}/$library")

    configuration("<http://proguard-rules.pro|proguard-rules.pro>")
}
m
y
This solution works only on jvm not on multiplatform
s
you are jumping into the problem that I’ve been trying to properly solve for a few weeks now.
y
i'm curious if it is possibility to solve this