-
Notifications
You must be signed in to change notification settings - Fork 36
Description
For my modular openJFX programs, the Gradle run task constructs a long command like that below. Looking in detail at the command constructed, I see it includes the bolded text a second time at the end after some java command line options. As a consequence, the text that follows the bolded text is passed to the application as arguments. The program does not and should not recognise these arguments.
The first thing to note is the problem does not show itself when I build for the classpath by deleting solely the module-info.java file.
If I try out the command in a Terminal deleting just the bolded text, the application starts without arguments and launches the JavaFX Application threads correctly. Similarly, if the application ignores all command line arguments, the JavaFX program works correctly despite arguments.
This behaviour applies to both Gradle 6.7 and Gradle 7.2.
I am using JDK 11 on openSuse.
Test Program
Here's my simple JavaFX Gradle program that expresses the problem.
gradle-problem-demo
The repository is public and you may copy the program if it would help solve this problem. You may adopt all or part of this program into Gradle tests. It is the purpose for which I wrote it.
I ran the program in a terminal/console (eliminating my IDE)
prompt> export JAVA_HOME=/usr/java/jdk-11
prompt> ./gradlew -i -x check -x test run
The command generated
I laid out the offending command nicely below and bolded the substring that was added twice:
/usr/java/jdk-11/bin/java
--add-modules javafx.controls,javafx.fxml,javafx.graphics
--module-path /home/emma/NetBeansProjects/Demo/build/libs/Demo.jar
:/home/emma/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-fxml/16/c7147c450773c3d4fd038ac9d1a6fdebbc3c11e0/javafx-fxml-16-linux.jar
:/home/emma/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-controls/16/116b127e512d23ddb84c62017c256e7f67f5b9eb/javafx-controls-16-linux.jar
:/home/emma/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-graphics/16/1bf2fd9f083daa2f492c4c58c4f7d5acb6f4b7d/javafx-graphics-16-linux.jar
:/home/emma/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-base/16/7d6b85ec89e99ea40c2a63bb1f23d43e05cd2557/javafx-base-16-linux.jar
--patch-module Demo=/home/emma/NetBeansProjects/Demo/build/resources/main
--module Demo/Demo.Main
-Dfile.encoding=UTF-8 -Duser.country=GB -Duser.language=en -Duser.variant
--module Demo/Demo.Main