Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions maven-wrapper-distribution/src/resources/only-mvnw.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
}

$MAVEN_WRAPPER_DISTS = $null
if ((Get-Item -Path $MAVEN_M2_PATH -Force).Target[0] -eq $null) {
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
$m2Item = Get-Item -Path $MAVEN_M2_PATH -Force
if ($m2Item.PSObject.Properties['Target'] -ne $null -and $m2Item.Target -ne $null) {
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

The new symlink detection condition will mis-handle the common non-symlink case where Get-Item ... .Target is an empty collection (not $null). In that scenario $m2Item.Target -ne $null is true, but $m2Item.Target[0] is $null, causing $MAVEN_WRAPPER_DISTS to become just "/wrapper/dists" (relative path) instead of using $MAVEN_M2_PATH. Update the condition to also require a non-null first target (or a non-empty Target collection) before using Target[0]; otherwise fall back to $MAVEN_M2_PATH/wrapper/dists.

Suggested change
if ($m2Item.PSObject.Properties['Target'] -ne $null -and $m2Item.Target -ne $null) {
if ($m2Item.PSObject.Properties['Target'] -ne $null -and $m2Item.Target -ne $null -and $m2Item.Target[0] -ne $null) {

Copilot uses AI. Check for mistakes.
$MAVEN_WRAPPER_DISTS = $m2Item.Target[0] + "/wrapper/dists"
} else {
$MAVEN_WRAPPER_DISTS = (Get-Item -Path $MAVEN_M2_PATH -Force).Target[0] + "/wrapper/dists"
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
}

$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
Expand Down