Tarun4201 opened a new pull request, #13239:
URL: https://github.com/apache/maven/pull/13239

   ## Summary
   
   Fixes **[MNG-8056](https://issues.apache.org/jira/browse/MNG-8056)** / 
closes **#10810**.
   
   When Maven is invoked from **Cygwin** on Windows with an absolute POSIX path:
   
   ```
   mvn -f /cygdrive/c/temp/parametertest/pom.xml validate
   mvn -s /cygdrive/c/temp/parametertest/.m2/settings.xml validate
   ```
   
   the JVM (a native Windows process) receives the Cygwin path verbatim. 
Because it does not understand the Cygwin virtual filesystem, it prepends `C:\` 
to the path, producing `C:\cygdrive\c\temp\...` which does not exist — causing 
the build to fail with:
   
   ```
   [FATAL] Non-readable POM C:\cygdrive\c\temp\parametertest\pom.xml
   [ERROR] The specified user settings file does not exist: 
C:\cygdrive\c\temp\...
   ```
   
   ## Root Cause
   
   The `bin/mvn` shell script already converts internal paths (`MAVEN_HOME`, 
`JAVA_HOME`, `CLASSWORLDS_CONF`, etc.) for Cygwin/MinGW using `cygpath`, but 
**user-supplied path arguments** (`$@`) passed via `-f`/`--file`, 
`-s`/`--settings`, `-gs`/`--global-settings`, `-st`/`--toolchains`, and 
`-gt`/`--global-toolchains` were passed through to the JVM unconverted.
   
   ## Fix
   
   Added a Cygwin-only post-processing step in 
`apache-maven/src/assembly/maven/bin/mvn` that:
   
   1. Defines a helper function `_cygwin_convert_paths()` which iterates over 
positional parameters.
   2. When it detects a path-accepting flag, it converts the **next argument** 
to Windows form via `cygpath --windows` — but **only** if it starts with `/` 
(i.e., it is an absolute POSIX path).
   3. Relative paths (`./relative/pom.xml`) and already-native Windows paths 
are left unchanged.
   4. MinGW/MSYS2 are **excluded** because their POSIX emulation layer already 
mangles paths automatically.
   
   ## Verification
   
   Tested scenarios (on Cygwin 3.5.x, Maven 3.9.6, Windows 10/11):
   
   | Command | Before | After |
   |---------|--------|-------|
   | `mvn -f /cygdrive/c/temp/pom.xml validate` | ❌ FATAL: Non-readable POM | ✅ 
BUILD SUCCESS |
   | `mvn -s /cygdrive/c/temp/.m2/settings.xml validate` | ❌ settings file does 
not exist | ✅ BUILD SUCCESS |
   | `mvn -f ./relative/pom.xml validate` | ✅ works | ✅ still works |
   | `mvn -f pom.xml validate` (no flag) | ✅ works | ✅ still works |
   
   ## Related
   
   - MNG-5812 — Project base dir not fully working in Cygwin
   - MNG-7621 — Parameter `-f` causes ignoring any `maven.config` (only on 
Windows)


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