Removed lots of unnecessary quotes and allowed passing quoted argument values
Closes #16189 Closes #16319
This commit is contained in:
parent
c6f13363b9
commit
1c9992fdae
2 changed files with 25 additions and 61 deletions
50
quarkus/dist/src/main/content/bin/kc.bat
vendored
50
quarkus/dist/src/main/content/bin/kc.bat
vendored
|
@ -8,18 +8,18 @@ setlocal
|
|||
|
||||
rem Get the program name before using shift as the command modify the variable ~nx0
|
||||
if "%OS%" == "Windows_NT" (
|
||||
set "PROGNAME=%~nx0%"
|
||||
set PROGNAME=%~nx0%
|
||||
) else (
|
||||
set "PROGNAME=kc.bat"
|
||||
set PROGNAME=kc.bat
|
||||
)
|
||||
|
||||
if "%OS%" == "Windows_NT" (
|
||||
set "DIRNAME=%~dp0%"
|
||||
set DIRNAME=%~dp0%
|
||||
) else (
|
||||
set DIRNAME=.\
|
||||
)
|
||||
|
||||
set "SERVER_OPTS=-Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dquarkus-log-max-startup-records=10000"
|
||||
set SERVER_OPTS=-Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dquarkus-log-max-startup-records=10000
|
||||
|
||||
set DEBUG_MODE=false
|
||||
set DEBUG_PORT_VAR=8787
|
||||
|
@ -28,13 +28,13 @@ set CONFIG_ARGS=
|
|||
|
||||
rem Read command-line args, the ~ removes the quotes from the parameter
|
||||
:READ-ARGS
|
||||
set "KEY=%~1"
|
||||
set KEY=%~1
|
||||
if "%KEY%" == "" (
|
||||
goto MAIN
|
||||
)
|
||||
if "%KEY%" == "--debug" (
|
||||
set "DEBUG_MODE=true"
|
||||
set "DEBUG_PORT_VAR=%~2"
|
||||
set DEBUG_MODE=true
|
||||
set DEBUG_PORT_VAR=%2
|
||||
if "%DEBUG_PORT_VAR%" == "" (
|
||||
set DEBUG_PORT_VAR=8787
|
||||
)
|
||||
|
@ -46,23 +46,23 @@ if "%KEY%" == "--debug" (
|
|||
goto READ-ARGS
|
||||
)
|
||||
if "%KEY%" == "start-dev" (
|
||||
set "CONFIG_ARGS=%CONFIG_ARGS% --profile=dev %KEY% "
|
||||
set CONFIG_ARGS=%CONFIG_ARGS% --profile=dev %KEY%
|
||||
shift
|
||||
goto READ-ARGS
|
||||
)
|
||||
if not "%KEY:~0,2%"=="--" if "%KEY:~0,2%"=="-D" (
|
||||
set "SERVER_OPTS=%SERVER_OPTS% %KEY%=%~2"
|
||||
set SERVER_OPTS=%SERVER_OPTS% %KEY%=%2
|
||||
shift
|
||||
)
|
||||
if not "%KEY:~0,2%"=="--" if not "%KEY:~0,1%"=="-" (
|
||||
set "CONFIG_ARGS=%CONFIG_ARGS% %KEY%"
|
||||
set CONFIG_ARGS=%CONFIG_ARGS% %KEY%
|
||||
)
|
||||
if not "%KEY:~0,2%"=="-D" (
|
||||
if "%KEY:~0,1%"=="-" (
|
||||
if "%~2"=="" (
|
||||
set "CONFIG_ARGS=%CONFIG_ARGS% %KEY%"
|
||||
set CONFIG_ARGS=%CONFIG_ARGS% %KEY%
|
||||
) else (
|
||||
set "CONFIG_ARGS=%CONFIG_ARGS% %KEY% %~2%"
|
||||
set CONFIG_ARGS=%CONFIG_ARGS% %KEY% %2%
|
||||
)
|
||||
shift
|
||||
)
|
||||
|
@ -87,11 +87,11 @@ set "JAVA_OPTS=%JAVA_OPTS% %JAVA_ADD_OPENS%"
|
|||
|
||||
if not "x%JAVA_OPTS_APPEND%" == "x" (
|
||||
echo "Appending additional Java properties to JAVA_OPTS: %JAVA_OPTS_APPEND%"
|
||||
set "JAVA_OPTS=%JAVA_OPTS% %JAVA_OPTS_APPEND%"
|
||||
set JAVA_OPTS=%JAVA_OPTS% %JAVA_OPTS_APPEND%
|
||||
)
|
||||
|
||||
if NOT "x%DEBUG%" == "x" (
|
||||
set "DEBUG_MODE=%DEBUG%
|
||||
set DEBUG_MODE=%DEBUG%
|
||||
)
|
||||
|
||||
if NOT "x%DEBUG_PORT%" == "x" (
|
||||
|
@ -106,14 +106,14 @@ rem Set debug settings if not already set
|
|||
if "%DEBUG_MODE%" == "true" (
|
||||
echo "%JAVA_OPTS%" | findstr /I "\-agentlib:jdwp" > nul
|
||||
if errorlevel == 1 (
|
||||
set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=%DEBUG_PORT_VAR%,server=y,suspend=%DEBUG_SUSPEND_VAR%"
|
||||
set JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=%DEBUG_PORT_VAR%,server=y,suspend=%DEBUG_SUSPEND_VAR%
|
||||
) else (
|
||||
echo Debug already enabled in JAVA_OPTS, ignoring --debug argument
|
||||
)
|
||||
)
|
||||
|
||||
rem Setup Keycloak specific properties
|
||||
set "JAVA_OPTS=-Dprogram.name=%PROGNAME% %JAVA_OPTS%"
|
||||
set JAVA_OPTS=-Dprogram.name=%PROGNAME% %JAVA_OPTS%
|
||||
|
||||
if "x%JAVA_HOME%" == "x" (
|
||||
set JAVA=java
|
||||
|
@ -128,22 +128,22 @@ if "x%JAVA_HOME%" == "x" (
|
|||
echo "%JAVA_HOME%\bin\java.exe" does not exist
|
||||
goto END
|
||||
)
|
||||
set "JAVA=%JAVA_HOME%\bin\java"
|
||||
set JAVA=%JAVA_HOME%\bin\java
|
||||
)
|
||||
)
|
||||
|
||||
set "CLASSPATH_OPTS=%DIRNAME%..\lib\quarkus-run.jar"
|
||||
|
||||
set "JAVA_RUN_OPTS=%JAVA_OPTS% -Dkc.home.dir="%DIRNAME%.." -Djboss.server.config.dir="%DIRNAME%..\conf" -Dkeycloak.theme.dir="%DIRNAME%..\themes" %SERVER_OPTS% -cp "%CLASSPATH_OPTS%" io.quarkus.bootstrap.runner.QuarkusEntryPoint %CONFIG_ARGS%"
|
||||
set JAVA_RUN_OPTS=%JAVA_OPTS% -Dkc.home.dir=%DIRNAME%.. -Djboss.server.config.dir=%DIRNAME%..\conf -Dkeycloak.theme.dir=%DIRNAME%..\themes %SERVER_OPTS% -cp %CLASSPATH_OPTS% io.quarkus.bootstrap.runner.QuarkusEntryPoint %CONFIG_ARGS%
|
||||
|
||||
SetLocal EnableDelayedExpansion
|
||||
|
||||
set "OPTIMIZED_OPTION=--optimized"
|
||||
set "HELP_LONG_OPTION=--help"
|
||||
set "BUILD_OPTION= build"
|
||||
set OPTIMIZED_OPTION=--optimized
|
||||
set HELP_LONG_OPTION=--help
|
||||
set BUILD_OPTION=build
|
||||
set IS_HELP_SHORT=false
|
||||
|
||||
echo "%CONFIG_ARGS%" | findstr /r "\<-h\>" > nul
|
||||
echo %CONFIG_ARGS% | findstr /r "\<-h\>" > nul
|
||||
|
||||
if not errorlevel == 1 (
|
||||
set IS_HELP_SHORT=true
|
||||
|
@ -159,17 +159,17 @@ set START_SERVER=true
|
|||
if "!CONFIG_ARGS:%OPTIMIZED_OPTION%=!"=="!CONFIG_ARGS!" if "!CONFIG_ARGS:%BUILD_OPTION%=!"=="!CONFIG_ARGS!" if "!CONFIG_ARGS:%HELP_LONG_OPTION%=!"=="!CONFIG_ARGS!" if "%IS_HELP_SHORT%" == "false" (
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
"%JAVA%" -Dkc.config.build-and-exit=true %JAVA_RUN_OPTS%
|
||||
%JAVA% -Dkc.config.build-and-exit=true %JAVA_RUN_OPTS%
|
||||
|
||||
if not !errorlevel! == 0 (
|
||||
set START_SERVER=false
|
||||
)
|
||||
|
||||
set "JAVA_RUN_OPTS=-Dkc.config.built=true %JAVA_RUN_OPTS%"
|
||||
set JAVA_RUN_OPTS=-Dkc.config.built=true %JAVA_RUN_OPTS%
|
||||
)
|
||||
|
||||
if "%START_SERVER%" == "true" (
|
||||
"%JAVA%" %JAVA_RUN_OPTS%
|
||||
%JAVA% %JAVA_RUN_OPTS%
|
||||
)
|
||||
|
||||
:END
|
||||
|
|
|
@ -65,7 +65,6 @@ public class LoggingDistTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnOs(value = { OS.LINUX, OS.MAC }, disabledReason = "different shell escaping behaviour on Windows.")
|
||||
@Launch({ "start-dev", "--log-level=off,org.keycloak:debug" })
|
||||
void testRootAndCategoryLevels(LaunchResult result) {
|
||||
CLIResult cliResult = (CLIResult) result;
|
||||
|
@ -74,16 +73,6 @@ public class LoggingDistTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnOs(value = { OS.WINDOWS }, disabledReason = "different shell escaping behaviour on Windows.")
|
||||
@Launch({ "start-dev", "--log-level=\"off,org.keycloak:debug\"" })
|
||||
void testWinRootAndCategoryLevels(LaunchResult result) {
|
||||
CLIResult cliResult = (CLIResult) result;
|
||||
assertFalse(cliResult.getOutput().contains("INFO [io.quarkus"));
|
||||
assertTrue(cliResult.getOutput().contains("DEBUG [org.keycloak"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnOs(value = { OS.LINUX, OS.MAC }, disabledReason = "different shell escaping behaviour on Windows.")
|
||||
@Launch({ "start-dev", "--log-level=off,org.keycloak:warn,debug" })
|
||||
void testSetLastRootLevelIfMultipleSet(LaunchResult result) {
|
||||
CLIResult cliResult = (CLIResult) result;
|
||||
|
@ -93,7 +82,6 @@ public class LoggingDistTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnOs(value = { OS.WINDOWS }, disabledReason = "different shell escaping behaviour on Windows.")
|
||||
@Launch({ "start-dev", "--log-level=\"off,org.keycloak:warn,debug\"" })
|
||||
void testWinSetLastRootLevelIfMultipleSet(LaunchResult result) {
|
||||
CLIResult cliResult = (CLIResult) result;
|
||||
|
@ -103,7 +91,6 @@ public class LoggingDistTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnOs(value = { OS.LINUX, OS.MAC }, disabledReason = "different shell escaping behaviour on Windows.")
|
||||
@Launch({ "start-dev", "--log-console-format=\"%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{1.}] %s%e%n\"" })
|
||||
void testSetLogFormat(LaunchResult result) {
|
||||
CLIResult cliResult = (CLIResult) result;
|
||||
|
@ -120,7 +107,6 @@ public class LoggingDistTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnOs(value = { OS.LINUX, OS.MAC }, disabledReason = "different shell escaping behaviour on Windows.")
|
||||
@Launch({ "start-dev", "--log-level=off,org.keycloak:debug,liquibase:debug", "--log-console-output=json" })
|
||||
void testLogLevelSettingsAppliedWhenJsonEnabled(LaunchResult result) {
|
||||
CLIResult cliResult = (CLIResult) result;
|
||||
|
@ -130,18 +116,6 @@ public class LoggingDistTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnOs(value = { OS.WINDOWS }, disabledReason = "different shell escaping behaviour on Windows.")
|
||||
@Launch({ "start-dev", "--log-level=\"off,org.keycloak:debug,liquibase:debug\"", "--log-console-output=json" })
|
||||
void testWinLogLevelSettingsAppliedWhenJsonEnabled(LaunchResult result) {
|
||||
CLIResult cliResult = (CLIResult) result;
|
||||
assertFalse(cliResult.getOutput().contains("\"loggerName\":\"io.quarkus\",\"level\":\"INFO\")"));
|
||||
assertTrue(cliResult.getOutput().contains("\"loggerName\":\"org.keycloak.services.resources.KeycloakApplication\",\"level\":\"DEBUG\""));
|
||||
assertTrue(cliResult.getOutput().contains("\"loggerName\":\"org.keycloak.protocol.oidc.OIDCWellKnownProviderFactory\",\"level\":\"DEBUG\""));
|
||||
assertTrue(cliResult.getOutput().contains("\"loggerName\":\"liquibase.servicelocator\",\"level\":\"FINE\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnOs(value = { OS.LINUX, OS.MAC }, disabledReason = "different shell escaping behaviour on Windows.")
|
||||
@Launch({ "start-dev", "--log=console,file"})
|
||||
void testKeycloakLogFileCreated(RawDistRootPath path) {
|
||||
Path logFilePath = Paths.get(path.getDistRootPath() + File.separator + LoggingOptions.DEFAULT_LOG_PATH);
|
||||
|
@ -150,16 +124,6 @@ public class LoggingDistTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnOs(value = { OS.WINDOWS }, disabledReason = "different shell escaping behaviour on Windows.")
|
||||
@Launch({ "start-dev", "--log=\"console,file\""})
|
||||
void testWinKeycloakLogFileCreated(RawDistRootPath path) {
|
||||
Path logFilePath = Paths.get(path.getDistRootPath() + File.separator + LoggingOptions.DEFAULT_LOG_PATH);
|
||||
File logFile = new File(logFilePath.toString());
|
||||
assertTrue(logFile.isFile(), "Log file does not exist!");
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledOnOs(value = { OS.LINUX, OS.MAC }, disabledReason = "different shell escaping behaviour on Windows.")
|
||||
@Launch({ "start-dev", "--log=console,file", "--log-file-format=\"%d{HH:mm:ss} %-5p [%c{1.}] (%t) %s%e%n\""})
|
||||
void testFileLoggingHasDifferentFormat(RawDistRootPath path) throws IOException {
|
||||
Path logFilePath = Paths.get(path.getDistRootPath() + File.separator + LoggingOptions.DEFAULT_LOG_PATH);
|
||||
|
|
Loading…
Reference in a new issue