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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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 ;)