Skip to content

Commit ff83212

Browse files
committed
Fix Windows jvm.config parsing and add debug logging to scripts
- mvn.cmd: Use 'cmd /c' to run JvmConfigParser in a subshell, ensuring file handles are properly released before reading the temp file. The previous 'for /f' with backticks approach did not correctly capture the Java output on Windows. - mvn, mvn.cmd: Add debug logging controlled by MAVEN_DEBUG_SCRIPT environment variable. When set, both scripts will output detailed information about jvm.config parsing, including: - Path to jvm.config file - Java command and arguments - Parser exit code and output - Final MAVEN_OPTS/JVM_CONFIG_MAVEN_OPTS value - Full JVM command line before launching Maven This helps diagnose jvm.config issues on CI systems where the log files are the primary debugging tool.
1 parent 7685323 commit ff83212

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,9 @@ for arg in "$@"; do
294294
cmd="$cmd \"$arg\""
295295
done
296296

297+
if [ -n "$MAVEN_DEBUG_SCRIPT" ]; then
298+
echo "[DEBUG] Launching JVM with command:" >&2
299+
echo "[DEBUG] $cmd" >&2
300+
fi
301+
297302
eval exec "$cmd"

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ for %%i in ("%MAVEN_HOME%"\boot\plexus-classworlds-*) do set LAUNCHER_JAR="%%i"
272272
set LAUNCHER_CLASS=org.codehaus.plexus.classworlds.launcher.Launcher
273273
if "%MAVEN_MAIN_CLASS%"=="" @set MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenCling
274274

275+
if defined MAVEN_DEBUG_SCRIPT (
276+
echo [DEBUG] Launching JVM with command:
277+
echo [DEBUG] "%JAVACMD%" %INTERNAL_MAVEN_OPTS% %MAVEN_OPTS% %JVM_CONFIG_MAVEN_OPTS% %MAVEN_DEBUG_OPTS% --enable-native-access=ALL-UNNAMED -classpath %LAUNCHER_JAR% "-Dclassworlds.conf=%CLASSWORLDS_CONF%" "-Dmaven.home=%MAVEN_HOME%" "-Dmaven.mainClass=%MAVEN_MAIN_CLASS%" "-Dlibrary.jline.path=%MAVEN_HOME%\lib\jline-native" "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %LAUNCHER_CLASS% %MAVEN_ARGS% %*
278+
)
279+
275280
"%JAVACMD%" ^
276281
%INTERNAL_MAVEN_OPTS% ^
277282
%MAVEN_OPTS% ^

0 commit comments

Comments
 (0)