gnodet-bot commented on code in PR #13239:
URL: https://github.com/apache/maven/pull/13239#discussion_r4072011437


##########
apache-maven/src/assembly/maven/bin/mvn:
##########
@@ -462,6 +462,41 @@ 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
+  _np=false
+  _count=$#
+  while [ $_count -gt 0 ]; do
+    _a="$1"
+    shift
+    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)

Review Comment:
   ⚠️ **Bug: `-st` is not a Maven CLI flag — toolchain paths are never 
converted.**
   
   `CommonsCliOptions.ALTERNATE_USER_TOOLCHAINS = "t"` (short option: `-t`). 
The flag `-st` does not exist in Maven 4's CLI; it's not defined anywhere in 
`CommonsCliOptions`. A user running `mvn -t /cygdrive/c/toolchains.xml` hits 
neither branch: the case doesn't match `-st`, `_np` stays `false`, and the 
Cygwin path reaches the JVM unconverted.
   
   Also missing from this line: `-ps` (`--project-settings`), `-is` 
(`--install-settings`), `-it` (`--install-toolchains`), and `-l` (`--log-file`) 
— all defined path-accepting flags in `CommonsCliOptions` that will silently 
fail on Cygwin with absolute paths.
   
   ```suggestion
           
-f|--file|-s|--settings|-ps|--project-settings|-is|--install-settings|-gs|--global-settings|-t|--toolchains|-it|--install-toolchains|-gt|--global-toolchains|-l|--log-file)
   ```



##########
apache-maven/src/assembly/maven/bin/mvn:
##########
@@ -462,6 +462,41 @@ 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
+  _np=false
+  _count=$#
+  while [ $_count -gt 0 ]; do
+    _a="$1"
+    shift
+    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 ;;
+        
--file=/*|--settings=/*|--global-settings=/*|--toolchains=/*|--global-toolchains=/*)

Review Comment:
   ⚠️ **Equals-form branch also missing the same flags.**
   
   The `--file=/*`, `--settings=/*`, etc. patterns are correct, but 
`--project-settings=/*`, `--install-settings=/*`, `--install-toolchains=/*`, 
and `--log-file=/*` are absent. A user who writes 
`--log-file=/cygdrive/c/logs/build.log` gets an unconverted path.
   
   ```suggestion
           
--file=/*|--settings=/*|--project-settings=/*|--install-settings=/*|--global-settings=/*|--toolchains=/*|--install-toolchains=/*|--global-toolchains=/*|--log-file=/*)
   ```



##########
apache-maven/src/assembly/maven/bin/mvn:
##########
@@ -537,3 +572,4 @@ if [ "$MAVEN_MAIN_CLASS" = 
"org.apache.maven.cling.MavenCling" ]; then
 else
   eval exec "$cmd" '"$@"'
 fi
+# End of file

Review Comment:
   🔧 **Nit: `# End of file` adds nothing.**
   
   No other file in this project uses this comment. Remove it.
   
   ```suggestion
   
   ```



-- 
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