openjfx / javafx-gradle-plugin

Gradle plugin that makes it easy to work with JavaFX 11+
https://openjfx.io/
BSD 3-Clause "New" or "Revised" License
354 stars 62 forks source link

Application receives wrong parameters when using the run task #119

Closed acisternino closed 1 year ago

acisternino commented 2 years ago

The plugin seems to rework the arguments of the java executable invoked to run the program when Gradle's run task is used.

What happens is that a few arguments meant for the java program are actually moved after the --module option and therefore end up forwarded as arguments to the program being run.

If the program does any sort of CLI argument parsing, it will fail with some form of "Unrecognized option: <some java option>".

When I run a simple modular application using ./gradlew --debug run I get this (excerpt):

...
2022-01-12T23:06:22.380+0100 [INFO] [org.javamodularity.moduleplugin.tasks.RunTaskMutator] jvmArgs for task run: [--add-modules, javafx.controls, --module-path, <all dependency jars>, --patch-module, com.example.javamodfx=/tmp/javafx-plugin-bug/javamodfx/build/resources/main, --module, com.example.javamodfx/com.example.javamodfx.App]
...
2022-01-12T23:06:22.381+0100 [INFO] [org.gradle.process.internal.DefaultExecHandle] Starting process 'command '/usr/lib/jvm/java-17-openjdk/bin/java''. Working directory: /tmp/javafx-plugin-bug/javamodfx Command: /usr/lib/jvm/java-17-openjdk/bin/java --add-modules javafx.controls --module-path <all dependency jars> --patch-module com.example.javamodfx=/tmp/javafx-plugin-bug/javamodfx/build/resources/main --module com.example.javamodfx/com.example.javamodfx.App -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant --module com.example.javamodfx/com.example.javamodfx.App
...
2022-01-12T23:06:23.192+0100 [QUIET] [system.out] Program args:
2022-01-12T23:06:23.192+0100 [QUIET] [system.out] -Dfile.encoding=UTF-8
2022-01-12T23:06:23.192+0100 [QUIET] [system.out] -Duser.country=US
2022-01-12T23:06:23.192+0100 [QUIET] [system.out] -Duser.language=en
2022-01-12T23:06:23.192+0100 [QUIET] [system.out] -Duser.variant
2022-01-12T23:06:23.192+0100 [QUIET] [system.out] --module
2022-01-12T23:06:23.192+0100 [QUIET] [system.out] com.example.javamodfx/com.example.javamodfx.App
...

The -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant --module com.example.javamodfx/com.example.javamodfx.App arguments are added after the first --module option.

The example project with more information is available here: https://github.com/acisternino/javafx-plugin-bug

java command manual page: https://docs.oracle.com/en/java/javase/17/docs/specs/man/java.html

Tested with 0.0.11-SNAPSHOT.

acisternino commented 1 year ago

I am closing this issue because the problem seems to be gone after some version updates.
Tested with: