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.27k stars 1.18k forks source link

Packaged .exe contains mangled copyright symbol #2373

Closed hakanai closed 1 month ago

hakanai commented 2 years ago

In the build script:

compose.desktop {
    application {
        mainClass = "garden.ephemeral.calculator.MainKt"
        // ...
        nativeDistributions {
            // ...
            copyright = "Copyright © 2022 $vendor"

            windows {
                upgradeUuid = "3e9ee76f-453c-4819-9371-41745b72b8cc"
                menuGroup = packageName
                iconFile.set(file("src/installers/AppIcon.ico"))
            }
            // ...
        }
    }
}

The resulting .app file has the © replaced by Å©:

image

Compared to an executable made by MS:

image

Most likely, jpackage is being run with Windows' default encoding and has to be set to UTF-8 so that it doesn't mangle the input?

Versions in play:

hakanai commented 2 years ago

Command being run:

[HOME]\.jdks\openjdk-17.0.1\bin\jpackage.exe @[PROJECT]\build\compose\tmp\createDistributable.args.txt

Contents of createDistributable.args.txt (decoded as UTF-8):

--input
"[PROJECT]\\build\\compose\\tmp\\createDistributable\\libs"
--runtime-image
"[PROJECT]\\build\\compose\\tmp\\main\\runtime"
--resource-dir
"[PROJECT]\\build\\compose\\tmp\\resources"
--java-options
"'-Dcompose.application.resources.dir=$APPDIR\\resources'"
--main-jar
"[PROJECT]\\build\\compose\\tmp\\createDistributable\\libs\\calculator-1.0.0-SNAPSHOT-f2d983a8aa0844e23ac35176b18dfbb.jar"
--main-class
"garden.ephemeral.calculator.MainKt"
--icon
"[PROJECT]\\src\\installers\\AppIcon.ico"
--java-options
"'-Dcompose.application.configure.swing.globals=true'"
--java-options
"'-Djpackage.app-version.unmangled=1.0.0-SNAPSHOT'"
--java-options
"'-Dskiko.library.path=$APPDIR'"
--type
"app-image"
--dest
"[PROJECT]\\build\\compose\\binaries\\main\\app"
--verbose
--name
"Calculator"
--description
"Simple calculator application built in Compose Desktop"
--copyright
"Copyright © 2022 Ephemeral Laboratories"
--app-version
"1.0.0"
--vendor
"Ephemeral Laboratories"
hakanai commented 2 years ago

It doesn't seem to say anything about this in the jpackage docs at all, but I'm guessing that adding -J-Dfile.encoding=UTF-8 might work for this executable too, as it commonly does work for other java tools...

It would have to go somewhere around here:

https://github.com/JetBrains/compose-jb/blob/master/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJvmToolOperationTask.kt#L71

And for obvious reasons can't be inside the argsFile.

okushnikov commented 4 months ago

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