Skip to content

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

@valnaumov

Description

@valnaumov

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?

def resourceName = noConsole ? '/windowsScriptTemplateJavaw.txt' : '/windowsScriptTemplate.txt'

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions