2

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?

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
  • Just to clarify (as I don't use Windows) is an `.scr` file just just the same binary as an `.exe` file except the extension difference? – D-Dᴙum Dec 11 '17 at 13:20
  • Short answer: no, not possible out-of-the box, long answer will follow for further details ;) – FibreFoX Dec 11 '17 at 13:26
  • @Kerry: correct. – Pablo Fernandez Dec 11 '17 at 13:28
  • @Pablo Sounds like a rename of the file might do the trick perhaps? I'm not a Gradle expert but I understand you can call regular Maven plugins from your Gradle scripts. Could you use the `copy-rename-maven-plugin` to do this? : https://coderplus.github.io/copy-rename-maven-plugin/ – D-Dᴙum Dec 11 '17 at 13:32
  • @Kerry the problem is not being able to do stuff within gradle, the "problem" lies inside the javapackager/JDK, as there are special files required by the javapackager/javafx-gradle-plugin. – FibreFoX Dec 11 '17 at 13:36
  • @FibreFoX: I saw your disclaimer. I bow to your greater knowledge and also acknowledge my misunderstanding of the issue. – D-Dᴙum Dec 11 '17 at 13:40
  • @Kerry no need for bowing down, the question was rather special topic ;) – FibreFoX Dec 11 '17 at 13:41
  • @Kerry: there's no need for a plug in, you can make a gradle task that just renames a file, but I need to rename after the .exe is created and before it is packaged for distribution. – Pablo Fernandez Dec 11 '17 at 13:55

1 Answers1

2

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

FibreFoX
  • 2,858
  • 1
  • 19
  • 41