diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/KeycloakMain.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/KeycloakMain.java index 3a83461ace..eb6b0e557d 100644 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/KeycloakMain.java +++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/KeycloakMain.java @@ -80,7 +80,7 @@ public class KeycloakMain implements QuarkusApplication { return; } - start(errorHandler, errStream); + start(errorHandler, errStream, args); return; } @@ -94,7 +94,7 @@ public class KeycloakMain implements QuarkusApplication { return cliArgs.size() == 2 && cliArgs.get(0).equals(Start.NAME) && cliArgs.stream().anyMatch(OPTIMIZED_BUILD_OPTION_LONG::equals); } - public static void start(ExecutionExceptionHandler errorHandler, PrintWriter errStream) { + public static void start(ExecutionExceptionHandler errorHandler, PrintWriter errStream, String[] args) { ClassLoader originalCl = Thread.currentThread().getContextClassLoader(); try { @@ -112,7 +112,7 @@ public class KeycloakMain implements QuarkusApplication { // as we are replacing the default exit handler, we need to force exit System.exit(exitCode); } - }); + }, args); } catch (Throwable cause) { errorHandler.error(errStream, String.format("Unexpected error when starting the server in (%s) mode", getKeycloakModeFromProfile(getProfileOrDefault("prod"))), diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/cli/command/AbstractStartCommand.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/cli/command/AbstractStartCommand.java index 3d935839e3..75ea3c5fe0 100644 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/cli/command/AbstractStartCommand.java +++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/cli/command/AbstractStartCommand.java @@ -34,7 +34,7 @@ public abstract class AbstractStartCommand extends AbstractCommand implements Ru public void run() { doBeforeRun(); CommandLine cmd = spec.commandLine(); - KeycloakMain.start((ExecutionExceptionHandler) cmd.getExecutionExceptionHandler(), cmd.getErr()); + KeycloakMain.start((ExecutionExceptionHandler) cmd.getExecutionExceptionHandler(), cmd.getErr(), cmd.getParseResult().originalArgs().toArray(new String[0])); } protected void doBeforeRun() { diff --git a/quarkus/server/src/main/java/org/keycloak/quarkus/_private/IDELauncher.java b/quarkus/server/src/main/java/org/keycloak/quarkus/_private/IDELauncher.java index ebdfc3152a..0dd254fb0a 100644 --- a/quarkus/server/src/main/java/org/keycloak/quarkus/_private/IDELauncher.java +++ b/quarkus/server/src/main/java/org/keycloak/quarkus/_private/IDELauncher.java @@ -1,12 +1,13 @@ package org.keycloak.quarkus._private; -import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; +import org.keycloak.quarkus.runtime.KeycloakMain; +import org.keycloak.quarkus.runtime.cli.Picocli; + import io.quarkus.runtime.Quarkus; /** @@ -28,7 +29,7 @@ import io.quarkus.runtime.Quarkus; public class IDELauncher { public static void main(String[] args) { - List devArgs = new ArrayList<>(); + List devArgs = new ArrayList<>(Picocli.parseArgs(args)); if (System.getProperty("kc.home.dir") == null) { // direct the auto-created files to the target folder, so they are cleaned by "mvn clean" @@ -37,12 +38,10 @@ public class IDELauncher { System.setProperty("kc.home.dir", path.toAbsolutePath().toString()); } - devArgs.addAll(Arrays.asList(args)); - if (devArgs.isEmpty()) { devArgs.add("start-dev"); } - Quarkus.run(devArgs.toArray(new String[devArgs.size()])); + Quarkus.run(KeycloakMain.class, devArgs.toArray(new String[devArgs.size()])); } }