Skip to content

[MNG-8018] Fix MSYS/Git-Bash path mis-detection on Windows #10906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

arturobernalg
Copy link
Member

Adds JUnit 5 Windows-only test for path normalisation.

Following this checklist to help us incorporate your
contribution quickly and easily:

  • [X ] Your pull request should address just one issue, without pulling in other changes.
  • [ X] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • [ X] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • [ X] Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • [ X] You have run the Core IT successfully.

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

…hs early in MavenCli.initialize(), fixing nested repo location and settings lookup.

Adds JUnit 5 Windows-only test for path normalisation.
@cstamas
Copy link
Member

cstamas commented Jul 10, 2025

FYI, on master the compat/maven-embedder is not used anymore (is left for compatibility). The CLI is working with impl/maven-cli instead.

What exact issue you have and it may mean you need to check out maven-cli as well.

@arturobernalg
Copy link
Member Author

FYI, on master the compat/maven-embedder is not used anymore (is left for compatibility). The CLI is working with impl/maven-cli instead.

What exact issue you have and it may mean you need to check out maven-cli as well.

done.


/**
* Turns “/d/projects/foo” into “D:\\projects\\foo”.
* Returns the original string if it isn't an MSYS-style path.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's MSYS?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimal System, is a software distribution and build platform for Windows

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSYS2?

Might need to spell this out. Is MSYS really the style of string here, or is this just a Windows path?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

POSIX-style Windows paths produced by MSYS2/Git Bash (and Cygwin), e.g. /c/Users/... or /cygdrive/c/.... The method converts those to native C:... and returns the input if it’s already a native Windows path.

* Turns “/d/projects/foo” into “D:\\projects\\foo”.
* Returns the original string if it isn't an MSYS-style path.
*/
static String msysToWindowsPath(final String p) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p --> path

if (p == null) {
return null;
}
final Matcher m = MSYS_PATH.matcher(p);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m --> matcher

if (org.codehaus.plexus.util.Os.isFamily("windows")) {
System.setProperty("user.home", msysToWindowsPath(System.getProperty("user.home")));

for (final String k : new String[] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k?

"alternateSettings",
"user.toolchains"
}) {
final String v = System.getProperty(k);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid single letter variable names

@arturobernalg arturobernalg requested a review from elharo August 11, 2025 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants