arturobernalg opened a new pull request, #473: URL: https://github.com/apache/maven-wrapper/pull/473
Fixes #442. `only-mvnw.cmd`'s PowerShell search for the extracted Maven distribution directory pipes `Get-ChildItem` into `ForEach-Object` with no early exit, so every directory under the download folder that contains `bin/<mvn-cmd>` overwrites `$actualDistributionDir`, and whichever one is enumerated last wins. The shell counterpart, `only-mvnw`, breaks on the first match in its (always alphabetically sorted) glob expansion. Whenever an extracted snapshot archive contains more than one directory with a Maven executable, `mvnw` and `mvnw.cmd` can resolve to a different `MAVEN_HOME`. I reproduced this directly with PowerShell: given two extracted directories each containing `bin/mvn`, the shell script always picked the alphabetically-first one while the batch script picked whichever one the filesystem happened to enumerate last, regardless of creation order. The fix replaces the `ForEach-Object` with a `foreach` loop over the directories sorted by name, breaking on the first match. This makes the selection deterministic and matches the shell script's first-match semantics regardless of filesystem enumeration order. I also added a decoy directory to the existing `snapshot_distribution_test` IT fixture (which already exercises the "zip filename != directory name" snapshot scenario). With the decoy present, I confirmed against the real zip generated by that IT's mock repository that the unfixed script picks the decoy while the fixed script correctly picks the real distribution, so a regression here will fail `verify.groovy`'s assertion on the Windows CI job. --- To make clear that you license your contribution under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0) check one of the following: - [x] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0) - [ ] I hereby declare that I have filed an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). https://claude.ai/code/session_0153qyh22xBMN1vPfWGz3jSH -- 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]
