diff --git a/maven-wrapper-distribution/src/resources/only-mvnw.cmd b/maven-wrapper-distribution/src/resources/only-mvnw.cmd index fd5f5ccd..98152505 100644 --- a/maven-wrapper-distribution/src/resources/only-mvnw.cmd +++ b/maven-wrapper-distribution/src/resources/only-mvnw.cmd @@ -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) { + $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"