diff options
| author | 2025-11-02 17:38:02 +0200 | |
|---|---|---|
| committer | 2026-01-10 16:18:09 +0200 | |
| commit | 03e46ed58ad195b76e1d9955e8ef7e881b3506cf (patch) | |
| tree | e3ab6c068fe1c2e6c7b1e499b41a650230c16d8c /mvnw.cmd | |
| parent | Remove shellcheck-precommit (diff) | |
| download | lv.enes:parent-03e46ed58ad195b76e1d9955e8ef7e881b3506cf.tar.gz lv.enes:parent-03e46ed58ad195b76e1d9955e8ef7e881b3506cf.tar.xz lv.enes:parent-03e46ed58ad195b76e1d9955e8ef7e881b3506cf.zip | |
Update wrapper-plugin
Diffstat (limited to 'mvnw.cmd')
| -rw-r--r-- | mvnw.cmd | 56 |
1 files changed, 48 insertions, 8 deletions
| @@ -19,7 +19,7 @@ | |||
| 19 | @REM ---------------------------------------------------------------------------- | 19 | @REM ---------------------------------------------------------------------------- |
| 20 | 20 | ||
| 21 | @REM ---------------------------------------------------------------------------- | 21 | @REM ---------------------------------------------------------------------------- |
| 22 | @REM Apache Maven Wrapper startup batch script, version 3.3.2 | 22 | @REM Apache Maven Wrapper startup batch script, version 3.3.4 |
| 23 | @REM | 23 | @REM |
| 24 | @REM Optional ENV vars | 24 | @REM Optional ENV vars |
| 25 | @REM MVNW_REPOURL - repo url base for downloading maven distribution | 25 | @REM MVNW_REPOURL - repo url base for downloading maven distribution |
| @@ -40,7 +40,7 @@ | |||
| 40 | @SET __MVNW_ARG0_NAME__= | 40 | @SET __MVNW_ARG0_NAME__= |
| 41 | @SET MVNW_USERNAME= | 41 | @SET MVNW_USERNAME= |
| 42 | @SET MVNW_PASSWORD= | 42 | @SET MVNW_PASSWORD= |
| 43 | @IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) | 43 | @IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*) |
| 44 | @echo Cannot start maven from wrapper >&2 && exit /b 1 | 44 | @echo Cannot start maven from wrapper >&2 && exit /b 1 |
| 45 | @GOTO :EOF | 45 | @GOTO :EOF |
| 46 | : end batch / begin powershell #> | 46 | : end batch / begin powershell #> |
| @@ -73,16 +73,30 @@ switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { | |||
| 73 | # apply MVNW_REPOURL and calculate MAVEN_HOME | 73 | # apply MVNW_REPOURL and calculate MAVEN_HOME |
| 74 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash> | 74 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash> |
| 75 | if ($env:MVNW_REPOURL) { | 75 | if ($env:MVNW_REPOURL) { |
| 76 | $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } | 76 | $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" } |
| 77 | $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" | 77 | $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')" |
| 78 | } | 78 | } |
| 79 | $distributionUrlName = $distributionUrl -replace '^.*/','' | 79 | $distributionUrlName = $distributionUrl -replace '^.*/','' |
| 80 | $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' | 80 | $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' |
| 81 | $MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" | 81 | |
| 82 | $MAVEN_M2_PATH = "$HOME/.m2" | ||
| 82 | if ($env:MAVEN_USER_HOME) { | 83 | if ($env:MAVEN_USER_HOME) { |
| 83 | $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" | 84 | $MAVEN_M2_PATH = "$env:MAVEN_USER_HOME" |
| 85 | } | ||
| 86 | |||
| 87 | if (-not (Test-Path -Path $MAVEN_M2_PATH)) { | ||
| 88 | New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null | ||
| 89 | } | ||
| 90 | |||
| 91 | $MAVEN_WRAPPER_DISTS = $null | ||
| 92 | if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) { | ||
| 93 | $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists" | ||
| 94 | } else { | ||
| 95 | $MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists" | ||
| 84 | } | 96 | } |
| 85 | $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' | 97 | |
| 98 | $MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain" | ||
| 99 | $MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' | ||
| 86 | $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" | 100 | $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" |
| 87 | 101 | ||
| 88 | if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { | 102 | if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { |
| @@ -134,7 +148,33 @@ if ($distributionSha256Sum) { | |||
| 134 | 148 | ||
| 135 | # unzip and move | 149 | # unzip and move |
| 136 | Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null | 150 | Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null |
| 137 | Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null | 151 | |
| 152 | # Find the actual extracted directory name (handles snapshots where filename != directory name) | ||
| 153 | $actualDistributionDir = "" | ||
| 154 | |||
| 155 | # First try the expected directory name (for regular distributions) | ||
| 156 | $expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain" | ||
| 157 | $expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD" | ||
| 158 | if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) { | ||
| 159 | $actualDistributionDir = $distributionUrlNameMain | ||
| 160 | } | ||
| 161 | |||
| 162 | # If not found, search for any directory with the Maven executable (for snapshots) | ||
| 163 | if (!$actualDistributionDir) { | ||
| 164 | Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object { | ||
| 165 | $testPath = Join-Path $_.FullName "bin/$MVN_CMD" | ||
| 166 | if (Test-Path -Path $testPath -PathType Leaf) { | ||
| 167 | $actualDistributionDir = $_.Name | ||
| 168 | } | ||
| 169 | } | ||
| 170 | } | ||
| 171 | |||
| 172 | if (!$actualDistributionDir) { | ||
| 173 | Write-Error "Could not find Maven distribution directory in extracted archive" | ||
| 174 | } | ||
| 175 | |||
| 176 | Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir" | ||
| 177 | Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null | ||
| 138 | try { | 178 | try { |
| 139 | Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null | 179 | Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null |
| 140 | } catch { | 180 | } catch { |