Tarun4201 commented on code in PR #13239:
URL: https://github.com/apache/maven/pull/13239#discussion_r4070068754


##########
apache-maven/src/assembly/maven/bin/mvn:
##########
@@ -462,6 +462,38 @@ if $cygwin || $mingw ; then
 fi
 MAVEN_PROJECTBASEDIR="$MAVEN_PROJECTBASEDIR_NATIVE"
 
+# MNG-8056: Under Cygwin, the JVM is a native Windows process and cannot 
resolve
+# Cygwin-style POSIX paths (e.g. /cygdrive/c/...) directly.  The internal paths
+# (MAVEN_HOME, CLASSWORLDS_CONF, JAVA_HOME, …) are already converted above, but
+# user-supplied paths passed via -f/--file, -s/--settings, 
-gs/--global-settings,
+# -st/--toolchains and -gt/--global-toolchains reach the JVM unconverted.
+# The loop below rewrites only those argument values that begin with '/' 
(absolute
+# POSIX paths); relative paths and already-Windows paths are left unchanged.
+# MinGW/MSYS2 perform automatic path mangling, so the fix is Cygwin-only.
+if $cygwin ; then
+  _cygwin_convert_paths() {
+    _out=; _np=false
+    for _a do
+      if $_np; then
+        case "$_a" in
+          /*) _a=$(cygpath --windows "$_a") ;;
+        esac
+        _np=false
+      else
+        case "$_a" in
+          
-f|--file|-s|--settings|-gs|--global-settings|-st|--toolchains|-gt|--global-toolchains)
+            _np=true ;;
+        esac
+      fi
+      # Accumulate single-quoted tokens, escaping any embedded single-quotes
+      _out="${_out}'$(printf '%s' "$_a" | sed "s/'/'\\\\''/g")' "
+    done
+    printf '%s' "$_out"
+  }
+  eval set -- "$(_cygwin_convert_paths "$@")"
+  unset -f _cygwin_convert_paths

Review Comment:
   Equals-form Argument Support (--file=): The script now explicitly intercepts 
and converts paths passed in the equals-form format (e.g. 
--file=/cygdrive/c/path, --settings=, --global-settings=, --toolchains=, 
--global-toolchains=). It splits the flag from the path, converts the path 
using cygpath, and dynamically reassembles them before passing to the JVM.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to