9

I'm using the JavaFX Gradle plugin to build my JavaFX application. Is it possible to have more than one executable built with different main classes? If so, how?

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622

1 Answers1

4

This is possible, as the underlying javapackager does support this.

As I'm understanding you correct, you have a project, where you have multiple entry-points and now you want to create native launchers/binaries for each of that entry-point. This is called "secondary launcher" inside the gradle plugin and even inside the javapackager.

To create multiple executables with the same bundle, just add this inside your buildfile:

jfx {
    // ... normal configuration ...

    // your secondary entry points, each will create a native executable (and one .cfg-file for each)
    secondaryLaunchers = [
        // second executable
        [
            appName: 'somethingDifferent'
            // will create the same executable, just with a different name (so this is demo-purpose only)
        ],
        // third executable
        [
            appName: 'somethingDifferent2',
            // specify your different entry-point
            mainClass: 'your.different.entrypoint.MainApp'
            // other possible entries: "jfxMainAppJarName", "jvmProperties", "jvmArgs", "userJvmArgs", "nativeReleaseVersion", "needShortcut", "needMenu", "vendor", "identifier"
        ]
    ]
}

Disclaimer: I'm the creator of the JavaFX Gradle plugin ;)

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
FibreFoX
  • 2,858
  • 1
  • 19
  • 41
  • 2
    Just a note: when you have any question, you might want to open an issue in the github-project or even get in direct contact via e-mail. This is often faster, but I can understand that SO is an excellent "research"-location ;) – FibreFoX Sep 29 '17 at 18:33
  • Suggestion:- [Example](https://github.com/FibreFoX/javafx-gradle-plugin/blob/master/README.md#example-buildgradle) misses that ideal line of documentation in that case. – Naman Oct 02 '17 at 07:46
  • Thank you @FibreFoX. These types of answers are rare and it should be SO should strive for. – Pablo Fernandez Oct 24 '17 at 08:20