JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.35k stars 1.18k forks source link

:packageDeb or :packageReleaseDeb fails at jpackage task #4622

Closed diareuse closed 2 months ago

diareuse commented 7 months ago

Describe the bug Packaging deb (or AppImage for that matter) fails on jpackage while using temurin-17 or openjdk-17 due to jpackage input error. Error says non-descriptively "Input length = 1", which I figured out means "Input directory does not exist". To further elaborate…

File build/compose/tmp/packageReleaseDeb.args.txt contains input line which points to build/compose/tmp/packageReleaseDeb/libs, where packageReleaseDeb directory DOES NOT get created for whatever reason and therefore there are literally no input files for jpackage to process.

Affected platforms

Versions

To Reproduce Steps and/or the code snippet to reproduce the behavior:

  1. Add TargetFormat.Deb to targetFormats block
  2. Run ./gradlew app:packageReleaseDistributionForCurrentOS

Expected behavior Task outputs .deb file to build/compose/binaries/**/*.deb

Screenshots n/a

Additional context n/a

diareuse commented 7 months ago

⚠️ There seems to be a lot of things involved in getting just the Linux to build, I'm afraid none of those things are in docs and nobody ever tried to build it. So if any member reads this, I'd love to ask you to at least include this in the docs - if not straight up changing the plugin internals and adding better error messages and failsaves.


It seems that apt package fakeroot is required together with binutils to build linux images. Therefore for anybody reading this:

sudo apt install -y binutils fakeroot

If you're also building .Dmg, .Msi and .AppImage, update the targetFormats to the following:

if (System.getProperty("os.name").toLowerCase().contains("linux"))
    targetFormats(TargetFormat.AppImage)
else
    targetFormats(TargetFormat.Dmg, TargetFormat.Msi)

Otherwise builds will fail on macOS in the current state (#3814)


Update toolchain to at-least JDK21, as JDK17 seems to have broken jpackage for whatever reason.

kotlin {
    jvmToolchain {
        languageVersion.set(JavaLanguageVersion.of(21))
    }
}

If you're also building with proguard, JDK18 is the latest with support by default, so you need to update the proguard as well:

buildTypes.release.proguard {
    version.set("7.4.0") // at least 7.4 is required, check https://www.guardsquare.com/manual/releasenotes for newer versions
}
Kpotko commented 7 months ago

Reproduced this issue with ubuntu 20.04 + openJdk 17 (also with coretto jdk 17)

With arch 6.2 + openJdk 17 "packageReleaseDistributionForCurrentOS" works as expected

okushnikov commented 3 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.