openjfx / javafx-maven-plugin

Maven plugin to run JavaFX 11+ applications
Apache License 2.0
371 stars 59 forks source link

commandlineArgs doesn't work with javafx:jlink goal #176

Open Martin819 opened 1 year ago

Martin819 commented 1 year ago

I have defined the commandlineArgs parameter, but it's never added to launcher.

I'm using Java 17 on Linux.

Configuration:

<plugin>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>0.0.8</version>
    <configuration>
        <stripJavaDebugAttributes>true</stripJavaDebugAttributes>
        <compress>2</compress>
        <noHeaderFiles>true</noHeaderFiles>
        <noManPages>true</noManPages>
        <launcher>appName</launcher>
        <options>-Xmx7G -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.virtualKeyboard=javafx</options>
        <commandlineArgs>test1 test2</commandlineArgs>
        <jlinkImageName>appImageName</jlinkImageName>
        <jlinkZipName>appName_${project.version}</jlinkZipName>
        <mainClass>com.example/com.example.App</mainClass>
        <jlinkVerbose>false</jlinkVerbose>
        <jmodsPath>${project.build}/dependency</jmodsPath>
    </configuration>
</plugin>

Expected launcher:

#!/bin/sh
JLINK_VM_OPTIONS="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.virtualKeyboard=javafx"
DIR=`dirname $0`
$DIR/java $JLINK_VM_OPTIONS -m com.example/com.example.App test1 test2 "$@"

Actual launcher:

#!/bin/sh
JLINK_VM_OPTIONS="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.virtualKeyboard=javafx"
DIR=`dirname $0`
$DIR/java $JLINK_VM_OPTIONS -m com.example/com.example.App "$@"
trashgod commented 9 months ago

If I understand correctly, <commandlineArgs> is a javafx:run option, which appears to work as expected. It looks like you can pass the same command-line parameters to the launcher via the shell special variable "$@":

./target/appImageName/bin/appName test1 test2