beryx / badass-runtime-plugin

Create a custom runtime image of your non-modular application
https://badass-runtime-plugin.beryx.org
Apache License 2.0
162 stars 21 forks source link

jpackage fails for mac os targetplatform #64

Closed lmyslinski closed 4 years ago

lmyslinski commented 4 years ago

Hi, I'm trying to create a Mac OS archive from Ubuntu 18.04 LTS running on WSL:

OpenJDK 14.0.1, Gradle 6.5.1

plugins {
...
    id 'org.beryx.runtime' version '1.11.2'
}
...
runtime {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    modules = ['java.naming', 'java.xml']

    targetPlatform("mac") {
        jdkHome = jdkDownload("https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.1%2B7/OpenJDK14U-jdk_x64_mac_hotspot_14.0.1_7.tar.gz") {
            archiveExtension = "tar.gz"
            pathToHome = "jdk-14.0.1+7/Contents/Home"
            overwrite = true
        }
    }

    jpackage {
        targetPlatformName="mac"
        installerType = 'pkg'
    }
}

runtime works, but jpackage fails with: > Task :jpackage FAILED WARNING: Using incubator modules: jdk.incubator.jpackage Error: Invalid or unsupported type: [pkg]

I tried to find an example of how to do a cross-system build but can't see any. Is there anything wrong with my config?

siordache commented 4 years ago

It's not possible to create a Mac OS archive from Ubuntu. In contrast to jlink, jpackage cannot create installers for other platforms. To create an archive for macOS, you must run jpackage on a macOS. You cannot do it on a Windows or Linux platform.

However, if your project is hosted on GitHub, you can use GitHub Actions to execute the Gradle build on different operating systems (Linux, macOS, Windows). See here an example workflow and the resulting archives.

lmyslinski commented 4 years ago

I had no idea about that - could I maybe suggest adding that to the docs of the plugin? The fact that you can target different platforms with the settings really had me convinced it's possible. I'll check out the github actions, thanks a lot!