Skip to content

Commit 8d99947

Browse files
authored
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. Additionally JVM_CONFIG_MAVEN_OPTS is introduced as its own variable to preserve the append behaviour.
1 parent bf87c1a commit 8d99947

File tree

1 file changed

+4
-2
lines changed
  • apache-maven/src/assembly/maven/bin

1 file changed

+4
-2
lines changed

apache-maven/src/assembly/maven/bin/mvn.cmd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ for /F "usebackq tokens=* delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.conf
204204
)
205205
)
206206
)
207-
@endlocal & set "MAVEN_OPTS=%MAVEN_OPTS% %JVM_CONFIG_MAVEN_OPTS%"
207+
@endlocal & set "JVM_CONFIG_MAVEN_OPTS=%JVM_CONFIG_MAVEN_OPTS%"
208208

209209
:endReadJvmConfig
210210

@@ -224,7 +224,7 @@ if "%~1"=="--debug" (
224224
echo Error: Unable to autodetect the YJP library location. Please set YJPLIB variable >&2
225225
exit /b 1
226226
)
227-
set "MAVEN_OPTS=-agentpath:%YJPLIB%=onexit=snapshot,onexit=memory,tracing,onlylocal %MAVEN_OPTS%"
227+
set "INTERNAL_MAVEN_OPTS=-agentpath:%YJPLIB%=onexit=snapshot,onexit=memory,tracing,onlylocal %INTERNAL_MAVEN_OPTS%"
228228
) else if "%~1"=="--enc" (
229229
set "MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenEncCling"
230230
) else if "%~1"=="--shell" (
@@ -248,7 +248,9 @@ set LAUNCHER_CLASS=org.codehaus.plexus.classworlds.launcher.Launcher
248248
if "%MAVEN_MAIN_CLASS%"=="" @set MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenCling
249249

250250
"%JAVACMD%" ^
251+
%INTERNAL_MAVEN_OPTS% ^
251252
%MAVEN_OPTS% ^
253+
%JVM_CONFIG_MAVEN_OPTS% ^
252254
%MAVEN_DEBUG_OPTS% ^
253255
--enable-native-access=ALL-UNNAMED ^
254256
-classpath %LAUNCHER_JAR% ^

0 commit comments

Comments
 (0)