beryx-gist / badass-runtime-example-javafx

A small JavaFX application that shows how to use the Badass Runtime Plugin
Apache License 2.0
26 stars 3 forks source link

Please add example for multiple builds (for different platforms) #35

Closed koppor closed 3 years ago

koppor commented 3 years ago

I added following to the config (of this repository), but the result is Since your runtime task is configured to generate images for multiple platforms, you must specify a targetPlatform for your jpackage task..

    targetPlatform("lin") {
        jdkHome = jdkDownload("https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.2%2B7/OpenJDK15U-jdk_x64_linux_hotspot_15.0.2_7.tar.gz")
    }

    targetPlatform("mac") {
        jdkHome = jdkDownload("https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.2%2B7/OpenJDK15U-jdk_x64_mac_hotspot_15.0.2_7.tar.gz") {
            downloadDir = "$buildDir/myMac"
            archiveName = "my-mac-jdk"
            archiveExtension = "tar.gz"
            pathToHome = "jdk-15.0.2+7/Contents/Home"
            overwrite = true
        }
    }

    targetPlatform("win") {
        jdkHome = jdkDownload("https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.2%2B7/OpenJDK15U-jdk_x64_windows_hotspot_15.0.2_7.zip")
    }
siordache commented 3 years ago

Yes, including such an example is a good idea. Thanks!

The error message tells you that you also need to add something like this:

jpackage {
    targetPlatformName = "mac"
    ....
}

I added your code to build.gradle.

koppor commented 3 years ago

Thank you for the quick action taken.

Think, I do not get "multiple". I thought, I could generate three images by one call. It seems that I can create one image for another runtime ("targetPlatformName"). I also think that currentOS should be the targetPlatformName, because if it is packed for Mac OS X. - Do I have a wrong assumption?

siordache commented 3 years ago

On your computer you can generate three images but only one installer.

Images are created by the runtime task (which uses jlink) in the build/image directory, while the installer is created by the jpackage task in the build/jpackage directory.

In contrast to jlink, jpackage is not able to produce installers for other platforms. That's why you need to specify the targetPlatformName in the jpackage block. To create an installer for Windows you need to run jpackage on a Windows platform, to create an installer for Linux you need to run jpackage on a Linux platform, and so on.

To create images and installers for my GitHub projects I don't usually use the targetPlatform method. Instead, I configure GitHub actions such as here to execute the build on different platforms and to upload the resulting artifacts.

koppor commented 3 years ago

@siordache Thank you for your explanation. Then I'll stick with the "traditional" method.

In case you are going to sign your binaries, here a link to our workflow: https://github.com/JabRef/jabref/blob/bb29baeb458e05ba3bf46d24105fbd3f8e097524/.github/workflows/deployment.yml#L98. With that, we do not hit https://bugs.openjdk.java.net/browse/JDK-8251892.

DesertCookie commented 3 years ago

jpackage { targetPlatformName = "mac" }

This throws me the error Could not set unknown property 'targetPlatformName' for task ':jpackage' of type org.beryx.jlink.JPackageTask..

Java 16.0.1, Gradle 7.0.2, JLink plugin 2.24.0.

siordache commented 3 years ago

You probably forgot to put it inside the jlink block:

jlink {
    jpackage {
        targetPlatformName = "mac"
    }
}