From 08831cba201bb45a5fa4395bdc49104abaeae3a2 Mon Sep 17 00:00:00 2001 From: armorbreak001 Date: Tue, 21 Apr 2026 13:01:22 +0800 Subject: [PATCH] fix(wrapper): resolve script directory from mvnw.cmd location instead of CWD When mvnw.cmd is invoked from a parent directory (e.g., c:\project\module\mvnw.cmd from c:\project), EXEC_DIR was set to the current working directory instead of the script's own directory. This caused the wrapper to look for .mvn/wrapper/ in the wrong place. Use pushd/popd with %~dp0 to resolve EXEC_DIR from the script's location, matching the behavior of the Unix mvnw script which uses dirname "$0". Fixes #247 --- maven-wrapper-distribution/src/resources/mvnw.cmd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/maven-wrapper-distribution/src/resources/mvnw.cmd b/maven-wrapper-distribution/src/resources/mvnw.cmd index 97fff177..1d4e14f8 100644 --- a/maven-wrapper-distribution/src/resources/mvnw.cmd +++ b/maven-wrapper-distribution/src/resources/mvnw.cmd @@ -87,7 +87,9 @@ goto error set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir +pushd "%~dp0" >nul 2>&1 set EXEC_DIR=%CD% +popd >nul 2>&1 set WDIR=%EXEC_DIR% :findBaseDir IF EXIST "%WDIR%"\.mvn goto baseDirFound