javajavafxjavafx-gradle-plugin

How do I change the extension of a launcher using JavaFX?


I'm building a JavaFX application and using the JavaFX packaging tools by means of the JavaFX-Gradle-plugin. I'm generating various launchers with this configuration:

jfx {
    mainClass = "tech.dashman.dashman.ConfiguratorApp"
    vendor = "Dashman"
    appName = "Dashman"
    nativeReleaseVersion = "1.0.0"

    secondaryLaunchers = [
            [
                    appName  : "Dashman Renderer",
                    mainClass: "tech.dashman.dashman.RendererApp",
                    needMenu : true
            ],
            [
                    appName  : "Dashman Displayer",
                    mainClass: "tech.dashman.dashman.DisplayerApp",
                    needMenu : true
            ],
            [
                    appName  : "Dashman Screensaver",
                    mainClass: "tech.dashman.dashman.WinScreensaverApp",
                    needMenu : false
            ]
    ]
}

but the last one, to be a proper Windows screensaver, it needs to have the .scr extension instead of .exe. How do I generate it with that name or rename it before the installation file is generated?


Solution

  • Out-of-the-box your request really is "impossible", but there is a solution, and some lines of explanation.

    The OracleJDK/OpenJDK has some really confusing way of bundling all tools together (and I'm still struggling with my progress to get it compatible with JDK9, but this is mostly due to missing spare time for this project). The internal javapackager-libs contain some so called "bundler", which do the main work for preparing the right jfx-jar, generating all required installer-creation-files and copying the native launcher (the exe-file) to the right place with the right name. This has a lot of restrictions: the installer-creation-file contains a lot of hard-coded stuff, including file-extensions and such pieces.

    I have created some small example-project for creating some OWN bundler, which you are required to re-implement for this: https://github.com/javafx-maven-plugin/javafx-maven-plugin/tree/master/src/it/23-simple-custom-bundler

    You will need to copy-paste some stuff from this file: http://hg.openjdk.java.net/openjfx/8u-dev/rt/file/bb53ab0b66a0/modules/fxpackager/src/main/java/com/oracle/tools/packager/windows/WinExeBundler.java

    Please take a close look to the used template, which can be at the resources-folder: http://hg.openjdk.java.net/openjfx/8u-dev/rt/file/bb53ab0b66a0/modules/fxpackager/src/main/resources/com/oracle/tools/packager/windows/template.iss#l42

    Please take care of the license these files are, I can not give legal advices, just spreading my thoughts about it here.

    Disclaimer: I'm the creator of the javafx-gradle-plugin