-
Notifications
You must be signed in to change notification settings - Fork 18
Description
When using the Gradle Application plugin, it is possible to pass arguments directly to the main(String[] args) method via the --args option:
./gradlew run --args="foo bar"This works as expected: the arguments are forwarded to the application’s main method.
However, when using the GluonFX Gradle plugin, the analogous task nativeRunAgent do not support --args. For example:
./gradlew nativeRunAgent --args="foo bar"The tasks execute, but the arguments are not passed to the application’s main(String[] args) method.
This makes nativeRunAgent inconsistent with the Application plugin’s run task, even though their purpose is very similar (running the app, with nativeRunAgent additionally generating/modifying GraalVM agent configs).
Expected Behavior
nativeRunAgentshould accept--argsand forward those arguments to the application’smain(String[] args), just like the Application plugin’sruntask.
Actual Behavior
--argsis ignored bynativeRunAgent.- The application receives no arguments in its
main(String[] args).
Steps to Reproduce
- Create a simple JavaFX/Java app with a
main(String[] args)that prints the arguments. - Run with the Application plugin:
→ Output shows
./gradlew run --args="foo bar"foo bar. - Run with GluonFX plugin:
→ Output shows no arguments.
./gradlew nativeRun --args="foo bar"
Question
Is there a supported way to pass arguments to main(String[] args) when using nativeRunAgent without modifying the plugin source?
If not, would it make sense to add --args support to these tasks, for consistency with the Application plugin?
Notes
- I can work around this by modifying the plugin source (adding an
@Option("args")property toNativeRunAgentTaskand forward those args into theJavaExectask, but I’d prefer to know if there’s an official or simpler way. - Happy to provide a PR if this feature is not yet supported.