beryx / badass-runtime-plugin

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

How to build a launcher both for CLI and GUI apps? #150

Open valnaumov opened 8 months ago

valnaumov commented 8 months ago

I have a class with a main method serving as an entry point for the application, both for graphical and command-line interfaces. If any command-line arguments are passed to the app, it starts in headless mode. If no arguments are specified, it starts with a GUI. When it starts with a GUI, I don't want the console window to be shown.

As far as I understand, I can create two launchers: one for GUI, one for CLI. Which is not very straightforward with this plugin though. But can I do it within the same launcher?

I had a clue that this could be done using a custom launcher script and choosing java or javaw based on whether the app was passed any command-line args or not. I assumed that this launcher scripts are somehow compiled into an executable launcher. Is this assumption correct?

https://github.com/beryx/badass-runtime-plugin/blob/e862997c031c76ee4e7a674b109c4797e2163cca/src/main/groovy/org/beryx/runtime/data/LauncherData.groovy#L70

I tried to check my assumption by providing a custom launcher script. See my demo. I inserted an echo command and also set environment variable DEBUG=TRUE to enable output on the script. Judging that it does not output any echo commands and does not behave the way I want it to (choose java/javaw), I conclude that it is not using this script for the launcher. It is not used for :run task either.

What is the purpose of unixScriptTemplate and windowsScriptTemplate launcher properties? The docs give a very vague description. Am I using it wrong in my demo? Why is not used?

yuricrona commented 5 months ago

Same, I also tried to put mkdir some absolute path, and tried to debug with windows process monitor, got nothing.

I noticed also since it depends on runtime task, it generates script and bootScripts also generated during Jpackage. Tried to modified both using gradle task but no luck.