Possible bug in Modular Java Gradle run task

I have been checking out Gradle builds on Netbeans 12.4 for a small modular javafx application that runs both as a command line application and when run without arguments the application runs as a JavaFX application.

I think I have found a bug in the run task which is part of the Gradle Application plug-in. The problem does not show itself when I delete the module-info.java file, creating a classpath build…

The run task constructs a rather over-complicated looking command like that below. It appears to include the bolded text twice when building a modular application. As a consequence, the text that follows the bolded text is passed to the application as arguments that it does not recognise. If I run the command in a Netbeans Terminal without the bolded text the application starts without arguments and launches the JavaFX Application threads.

This behaviour applies to both Gradle 6.7 and Gradle 7.2. I am using Netbeans 12.4 on JDK-11 on Linux.

Is this a known or new bug?


Here’s the generated command:

/usr/java/jdk-11/bin/java --add-modules javafx.controls,javafx.fxml,javafx.graphics --module-path /home/emma/NetBeansProjects/CleanFilenameG/build/libs/CleanFilenameG-0.3.jar:/home/emma/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.14.1/9141212b8507ab50a45525b545b39d224614528b/log4j-core-2.14.1.jar:/home/emma/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.14.1/cd8858fbbde69f46bce8db1152c18a43328aae78/log4j-api-2.14.1.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 CleanFilenameG=/home/emma/NetBeansProjects/CleanFilenameG/build/resources/main –module CleanFilenameG/cleanfilename.CleanFilename -Dfile.encoding=UTF-8 -Duser.country=GB -Duser.language=en -Duser.variant --module CleanFilenameG/cleanfilename.CleanFilename

Here’s a JavaFX program on GitHub that demo’s the problem

A fix has been developed.
To use the fix put this in the plugins { } block before the javafx plugin of your build.gradle file.

// Java Modularity plugin
id 'org.javamodularity.moduleplugin' version '1.8.10'

// JavaFX Plugin
// See https://github.com/openjfx/javafx-gradle-plugin
id 'org.openjfx.javafxplugin' version '0.0.10'

My GitHub demo now incorporates this fix. I’ll leave the demo up for a few weeks in case someone finds it useful.