You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2025/07/24 09:47:57 UTC
(maven) branch maven-3.9.x updated: Avoid parsing MAVEN_OPTS (3.9.x) (#10969)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch maven-3.9.x
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/maven-3.9.x by this push:
new 256a441760 Avoid parsing MAVEN_OPTS (3.9.x) (#10969)
256a441760 is described below
commit 256a441760de9d140263d75818f048538d71b256
Author: Bob <16...@users.noreply.github.com>
AuthorDate: Thu Jul 24 19:47:51 2025 +1000
Avoid parsing MAVEN_OPTS (3.9.x) (#10969)
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.
Co-authored-by: Bob <Bo...@users.noreply.github.com>
---
apache-maven/src/bin/mvn.cmd | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/apache-maven/src/bin/mvn.cmd b/apache-maven/src/bin/mvn.cmd
index 972c39eaf2..affbe43182 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
@@ -175,11 +179,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% ^