Describe the bug
When running applications in Maven with more than one command line argument for -Dquarkus.args, Quarkus is not capable of handling those arguments and passing them to the application
Expected behavior
In the example code linked below in reproduction steps, the expected behaviour is for the program to take 2 arguments (--name and --day) which should produce a message of Hello {name}! Today is {day}
Actual behavior
The console outputs help text for either Java or Maven
To Reproduce
Steps to reproduce the behavior:
./mvnw quarkus:dev -Dquarkus.args="--name=Bob --day=Monday" (or any other values for the arguments)Environment (please complete the following information):
uname -a or ver: Microsoft Windows [Version 10.0.17763.1282]java -version: openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)
20.1.0Quarkus 1.5.2.Finalmvnw --version or gradlew --version): Apache Maven 3.6.3Additional context
Also tried the following:
./mvnw quarkus:dev -Dquarkus.args=\"--name=Bob --day=Monday\"I wonder if this is a Windows cmd issue... In any case we probably should be going the extra mile to split the arguments
I can confirm this fails in Fedora 32 too with the following exception:
Exception in thread "main" java.lang.RuntimeException: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for null
at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:138)
at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:57)
Caused by: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for null
at io.quarkus.bootstrap.BootstrapAppModelFactory.resolveAppModel(BootstrapAppModelFactory.java:313)
at io.quarkus.bootstrap.app.QuarkusBootstrap.bootstrap(QuarkusBootstrap.java:157)
at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:131)
... 1 more
Caused by: java.lang.IllegalStateException: Failed to parse command line arguments [, -Ddebug, -Dsuspend, -Dquarkus.args=--name=Bob, --day=Monday, quarkus:dev]
at io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptions.invokeParser(BootstrapMavenOptions.java:199)
at io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptions.parse(BootstrapMavenOptions.java:85)
at io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptions.newInstance(BootstrapMavenOptions.java:106)
at io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptions.newInstance(BootstrapMavenOptions.java:102)
at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.getCliOptions(BootstrapMavenContext.java:176)
at io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext.<init>(BootstrapMavenContext.java:144)
at io.quarkus.bootstrap.BootstrapAppModelFactory.createBootstrapMavenContext(BootstrapAppModelFactory.java:215)
at io.quarkus.bootstrap.BootstrapAppModelFactory.loadWorkspace(BootstrapAppModelFactory.java:325)
at io.quarkus.bootstrap.BootstrapAppModelFactory.resolveAppModel(BootstrapAppModelFactory.java:250)
... 3 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptions.invokeParser(BootstrapMavenOptions.java:195)
... 11 more
Caused by: java.lang.IllegalStateException: Failed to parse Maven command line arguments
at io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptionsParser.parse(BootstrapMavenOptionsParser.java:16)
... 16 more
Caused by: org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: --day=Monday
at org.apache.commons.cli.Parser.processOption(Parser.java:383)
at org.apache.commons.cli.Parser.parse(Parser.java:210)
at org.apache.commons.cli.Parser.parse(Parser.java:88)
at org.apache.maven.cli.CLIManager.parse(CLIManager.java:162)
at io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptionsParser.parse(BootstrapMavenOptionsParser.java:14)
... 16 more
Interesting!
I managed to make it work by changing this line:
https://github.com/takari/maven-wrapper/blob/7039b05cfec0e8a729d6d84670433912e00c6aa5/mvnw#L301
to
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG \"$@\""
@rt-chang can you perform this change locally and let me know if that works for you?
UPDATE: Apparently this simply skips the options passed in the io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptionsParser#parse, so it's not a decent solution
I was unable to get it to work locally. It produced the help text for Java's CLI
I noticed when looking at the related PR for this feature, that Quarkus handles the arguments differently for quarkus.args versus jvm args. Not sure if this is the root cause though
@rt-chang Good catch! I reused the same class to parse the JVM args and apparently it works. Let me provide a PR
I see this was closed but the linked merge seems to reference "not working on windows".
Just wanted to confirm that is the case or to expect this to be working on windows for Quarkus 1.6
Thank you for your time.
===============
Edit - Confirmed this not working with 1.7.0 on Windows.
Is there a separate ticket for that or should one be created?
Thank you
@hummerpj I don't think there is one specifically for Windows, mind creating one? Thanks
@gastaldi
I think I spoke too soon, I was working on creating a separate project to recreate it but appears to be working fine on windows.
Carry on :D
I'm still having this issue using quarkus version 1.8.1.FINAL on my ubuntu 20.04 machine.
Can sombody confirm this?
@fleigm I don't have Ubuntu. Can you open a new issue with a reproducer? Thanks!