diff --git a/devtools/cli/src/main/java/io/quarkus/cli/build/BuildSystemRunner.java b/devtools/cli/src/main/java/io/quarkus/cli/build/BuildSystemRunner.java index 86fb31863deab..5a6fd63209125 100644 --- a/devtools/cli/src/main/java/io/quarkus/cli/build/BuildSystemRunner.java +++ b/devtools/cli/src/main/java/io/quarkus/cli/build/BuildSystemRunner.java @@ -71,10 +71,16 @@ default BuildCommandArgs prependExecutable(ArrayDeque args) { default void paramsToQuarkusArgs(List params, ArrayDeque args) { if (!params.isEmpty()) { - args.add("-Dquarkus.args='" + String.join(" ", params) + "'"); + args.add("-Dquarkus.args=" + String.join(" ", wrapWithDoubleQuotes(params))); } } + default List wrapWithDoubleQuotes(List stringsToWrap) { + return stringsToWrap.stream() + .map("\"%s\""::formatted) + .toList(); + } + default List flattenMappedProperties(Map props) { List result = new ArrayList<>(); props.entrySet().forEach(x -> { diff --git a/devtools/cli/src/test/java/io/quarkus/cli/CliProjectGradleTest.java b/devtools/cli/src/test/java/io/quarkus/cli/CliProjectGradleTest.java index 354ed4055f511..eb11e76ff4b91 100644 --- a/devtools/cli/src/test/java/io/quarkus/cli/CliProjectGradleTest.java +++ b/devtools/cli/src/test/java/io/quarkus/cli/CliProjectGradleTest.java @@ -348,8 +348,8 @@ public void testDevOptions() throws Exception { Assertions.assertFalse(result.stdout.contains("-Dsuspend"), "gradle command should not specify '-Dsuspend'\n" + result); - Assertions.assertTrue(result.stdout.contains("-Dquarkus.args='arg1 arg2'"), - "gradle command should not specify -Dquarkus.args='arg1 arg2'\n" + result); + Assertions.assertTrue(result.stdout.contains("-Dquarkus.args=\"arg1\" \"arg2\""), + "gradle command should not specify -Dquarkus.args=\"arg1\" \"arg2\"\n" + result); // 4 TEST MODE: test --clean --debug --suspend --offline result = CliDriver.execute(project, "test", "-e", "--dry-run", @@ -366,6 +366,13 @@ public void testDevOptions() throws Exception { "Expected OK return code. Result:\n" + result); Assertions.assertTrue(result.stdout.contains("Run current project in test mode"), result.toString()); Assertions.assertTrue(result.stdout.contains("--tests FooTest"), result.toString()); + + // 6 TEST MODE: Two word argument + result = CliDriver.execute(project, "dev", "-e", "--dry-run", + "--no-suspend", "--debug-host=0.0.0.0", "--debug-port=8008", "--debug-mode=connect", "--", "arg1 arg2"); + + Assertions.assertTrue(result.stdout.contains("-Dquarkus.args=\"arg1 arg2\""), + "mvn command should not specify -Dquarkus.args=\"arg1 arg2\"\n" + result); } @Test diff --git a/devtools/cli/src/test/java/io/quarkus/cli/CliProjectMavenTest.java b/devtools/cli/src/test/java/io/quarkus/cli/CliProjectMavenTest.java index 180795f1ae0e3..1374448c5ab51 100644 --- a/devtools/cli/src/test/java/io/quarkus/cli/CliProjectMavenTest.java +++ b/devtools/cli/src/test/java/io/quarkus/cli/CliProjectMavenTest.java @@ -273,8 +273,8 @@ public void testDevTestOptions() throws Exception { Assertions.assertFalse(result.stdout.contains("-Dsuspend"), "mvn command should not specify '-Dsuspend'\n" + result); - Assertions.assertTrue(result.stdout.contains("-Dquarkus.args='arg1 arg2'"), - "mvn command should not specify -Dquarkus.args='arg1 arg2'\n" + result); + Assertions.assertTrue(result.stdout.contains("-Dquarkus.args=\"arg1\" \"arg2\""), + "mvn command should not specify -Dquarkus.args=\"arg1\" \"arg2\"\n" + result); // 4 TEST MODE: test --clean --debug --suspend --offline result = CliDriver.execute(project, "test", "-e", "--dry-run", @@ -291,6 +291,13 @@ public void testDevTestOptions() throws Exception { "Expected OK return code. Result:\n" + result); Assertions.assertTrue(result.stdout.contains("Run current project in test mode"), result.toString()); Assertions.assertTrue(result.stdout.contains("-Dtest=FooTest"), result.toString()); + + // 6 TEST MODE: Two word argument + result = CliDriver.execute(project, "dev", "-e", "--dry-run", + "--no-suspend", "--debug-host=0.0.0.0", "--debug-port=8008", "--debug-mode=connect", "--", "arg1 arg2"); + + Assertions.assertTrue(result.stdout.contains("-Dquarkus.args=\"arg1 arg2\""), + "mvn command should not specify -Dquarkus.args=\"arg1 arg2\"\n" + result); } @Test