You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "fp024 (via GitHub)" <gi...@apache.org> on 2024/05/31 12:14:41 UTC
[PR] Workaround: Windows Junction Link handling issue in mvnw.cmd [maven-wrapper]
fp024 opened a new pull request, #143:
URL: https://github.com/apache/maven-wrapper/pull/143
hello.
I applied to join Apache JIRA, but I wasn't sure if I would be approved as a member, so I submitted a PR for issue reporting purposes.
## Issue
`Move-Item` fails when the `.m2` path is in the following state:
* Junction link reference status of m2 directory on my system

* `G:\Maven\.m2` is the actual path.
The argument value of `-Destnation` in PowerShell's `Move-Item` command must be an actual path, but in my environment, it is a **junction link** and is bound to fail.
## Workaround
So I modified the code to get `$MAVEN_HOME_PARENT` as follows.
```powershell
# ...
$MAVEN_M2_PATH = "$HOME/.m2"
if ($env:MAVEN_USER_HOME) {
$MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
}
if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
}
$MAVEN_WRAPPER_DISTS = $null
if ((Get-Item $MAVEN_M2_PATH).Target -eq $null) {
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
} else {
$MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
}
$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
# ...
```
* The actual path could be obtained by obtaining Target[0] on the Item obtained with Get-Item -Path {Path}.
* If the path passed as an argument is an actual path rather than a junction link path, it is `$null`.
This PR commit was posted for issue reporting purposes only, so it may require expert editing.
Please confirm. thank you have a good day. π
---
Following this checklist to help us incorporate your
contribution quickly and easily:
- [x] Make sure there is a [[JIRA issue](https://issues.apache.org/jira/browse/MWRAPPER)](https://issues.apache.org/jira/browse/MWRAPPER) filed
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
- [x] Each commit in the pull request should have a meaningful subject line and body.
- [ ] Format the pull request title like `[MWRAPPER-XXX] - Fixes bug in ApproximateQuantiles`,
where you replace `MWRAPPER-XXX` with the appropriate JIRA issue. Best practice
is to use the JIRA issue title in the pull request title and in the first line of the
commit message.
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [x] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will
be performed on your pull request automatically.
- [ ] You have run the integration tests successfully (`mvn -Prun-its clean verify`).
If your pull request is about ~20 lines of code you don't need to sign an
[[Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf)](https://www.apache.org/licenses/icla.pdf) 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](http://www.apache.org/licenses/LICENSE-2.0)](http://www.apache.org/licenses/LICENSE-2.0)
you have to acknowledge this by using the following check-box.
- [ ] I hereby declare this contribution to be licenced under the [[Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)](http://www.apache.org/licenses/LICENSE-2.0)
- [ ] In any other case, please file an [[Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf)](https://www.apache.org/licenses/icla.pdf).
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Workaround: Windows Junction Link handling issue in mvnw.cmd [maven-wrapper]
Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #143:
URL: https://github.com/apache/maven-wrapper/pull/143#issuecomment-2141976433
@michael-o ping
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Workaround: Windows Junction Link handling issue in mvnw.cmd [maven-wrapper]
Posted by "fp024 (via GitHub)" <gi...@apache.org>.
fp024 commented on PR #143:
URL: https://github.com/apache/maven-wrapper/pull/143#issuecomment-2143129380
hello.
I received a GitHub Action build failure email and checked the code again.
Here's what I saw in PowerShell ISE after separating that part:
```powershell
# Set MAVEN_USER_HOME manually
# $env:MAVEN_USER_HOME="D:/MAVEN2/.m2"
$env:MAVEN_USER_HOME=$null
$MAVEN_M2_PATH = "$HOME/.m2"
if ($env:MAVEN_USER_HOME) {
$MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
}
Write-Output "MAVEN_M2_PATH: $MAVEN_M2_PATH"
if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
}
$MAVEN_WRAPPER_DISTS = $null
if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) { # π‘Re-edited part
Write-Output "is null: actual path"
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
Write-Output "MAVEN_WRAPPER_DISTS: $MAVEN_WRAPPER_DISTS"
} else {
$MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
Write-Output "not null: junction path -> actual path"
Write-Output "MAVEN_WRAPPER_DISTS: $MAVEN_WRAPPER_DISTS"
}
```
### When MAVEN_USER_HOME is not set as an environment variable
* MAVEN_M2_PATH="HOME/.m2"

* `C:\Users\{UserName}/.m2` is the junction path
* `G:\Maven\m2/wrapper/dists` is the actual path
* The actual path to the picture in the first comment is incorrect: my actual path environment is `G:\Maven\m2`, not `G:\Maven\.m2`.
### When MAVEN_USER_HOME is set as an environment variable
* MAVEN_M2_PATH="D:/MAVEN2/.m2"
* `D:/MAVEN2/.m2` is the actual path

* Compared to the first uploaded commit, we changed it to always check the junction link condition with Target[0].
* https://github.com/apache/maven-wrapper/compare/eaddcc6d7d1490059e286eef80a2176e560e3d6e..cefb22592fe3397c7652bc3a3866bd73cf5ec8c5
thank you π
--
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org