From 2d9ceeea88857df081e603bf1049f7fef64acaf8 Mon Sep 17 00:00:00 2001 From: Bob Date: Mon, 21 Jul 2025 17:17:53 +1000 Subject: [PATCH 1/2] Avoid parsing MAVEN_OPTS Fixes #10937 by introducing an additional INTERNAL_MAVEN_OPTS for any arguments that need to be inserted by the script. Parsing the externally-defined MAVEN_OPTS variable can lead to incorrect processing of quotes and special characters, so use the separate variable to avoid doing so. --- apache-maven/src/bin/mvn.cmd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apache-maven/src/bin/mvn.cmd b/apache-maven/src/bin/mvn.cmd index 972c39eaf26c..255acf234068 100644 --- a/apache-maven/src/bin/mvn.cmd +++ b/apache-maven/src/bin/mvn.cmd @@ -175,11 +175,12 @@ set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher @REM MNG-8248 "%JAVACMD%" --enable-native-access=ALL-UNNAMED -version >nul 2>&1 if ERRORLEVEL 1 goto skipEnableNativeAccess -set "MAVEN_OPTS=--enable-native-access=ALL-UNNAMED %MAVEN_OPTS%" +set "INTERNAL_MAVEN_OPTS=--enable-native-access=ALL-UNNAMED %INTERNAL_MAVEN_OPTS%" :skipEnableNativeAccess "%JAVACMD%" ^ %JVM_CONFIG_MAVEN_PROPS% ^ + %INTERNAL_MAVEN_OPTS% ^ %MAVEN_OPTS% ^ %MAVEN_DEBUG_OPTS% ^ -classpath %CLASSWORLDS_JAR% ^ From 0fc61fd8d2ecda830b7aa417053e6f7cccb447f6 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 22 Jul 2025 01:45:42 +1000 Subject: [PATCH 2/2] Avoid parsing MAVEN_OPTS Fixes #10937 by introducing an additional INTERNAL_MAVEN_OPTS for any arguments that need to be inserted by the script. Parsing the externally-defined MAVEN_OPTS variable can lead to incorrect processing of quotes and special characters, so use the separate variable to avoid doing so. --- apache-maven/src/bin/mvn.cmd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apache-maven/src/bin/mvn.cmd b/apache-maven/src/bin/mvn.cmd index 255acf234068..affbe4318216 100644 --- a/apache-maven/src/bin/mvn.cmd +++ b/apache-maven/src/bin/mvn.cmd @@ -33,6 +33,10 @@ @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' @if "%MAVEN_BATCH_ECHO%"=="on" echo %MAVEN_BATCH_ECHO% +@REM Clear/define a variable for any options to be inserted via script +@REM We want to avoid trying to parse the external MAVEN_OPTS variable +SET INTERNAL_MAVEN_OPTS= + @REM Execute a user defined script before this one if not "%MAVEN_SKIP_RC%"=="" goto skipRcPre @REM check for pre script, once with legacy .bat ending and once with .cmd ending