Since version 3.3.0, we cannot download Maven distribution if we set MVNW_REPOURL on Windows platforms (Windows 10, Windows Server 2022) with script-only.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.z
```ip
Current result (3.3.2)
``` text
PS C:\workspace\poc\maven-build> .\mvnw.cmd -v
icm : Exception lors de l'appel de « DownloadFile » avec « 2 » argument(s) : « Le serveur distant a retourné une erreur : (404) Introuvable. »
Au caractère Ligne:1 : 72
+ ... 'mvnw.cmd'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-Command], MethodInvocationException
+ FullyQualifiedErrorId : WebException,Microsoft.PowerShell.Commands.InvokeCommandCommand
Commande ECHO activée.
Cannot start maven from wrapper
Expected result was
PS C:\workspace\poc\maven-build> .\mvnw.cmd -v
COMMENTAIRES : Couldn't find MAVEN_HOME, downloading and installing it ...
COMMENTAIRES : Downloading from: https://nexus.local/repository/maven-repo/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
COMMENTAIRES : Downloading to: C:\Users\jahk04\AppData\Local\Temp\tmp1DCA.tmp.dir/apache-maven-3.9.9-bin.zip
If MVNW_VERBOSE is also set to true we can have some hints
PS C:\workspace\poc\maven-build> .\mvnw.cmd -v
COMMENTAIRES : Couldn't find MAVEN_HOME, downloading and installing it ...
COMMENTAIRES : Downloading from: https://nexus.local/repository/maven-repo/maven/mvnd/https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
COMMENTAIRES : Downloading to: C:\Users\jahk04\AppData\Local\Temp\tmp950D.tmp.dir/apache-maven-3.9.9-bin.zip
icm : Exception lors de l'appel de «DownloadFile» avec «2» argument(s): «Le serveur distant a retourné une erreur:
(404) Introuvable.»
Au caractère Ligne:1 : 72
+ ... 'mvnw.cmd'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-Command], MethodInvocationException
+ FullyQualifiedErrorId : WebException,Microsoft.PowerShell.Commands.InvokeCommandCommand
Commande ECHO activée.
Cannot start maven from wrapper
$env:MVNW_REPOURL is concatened with mvnd context and the actual distributionUrl defined inside .mvn/wrapper/maven-wrapper.properties
Looking at script mvnw.cmd, it seems that the following block is at fault with two "bugs"
USE_MVND evaluation is incorrect
string substitution of distributionUrl is incorrect
# apply MVNW_REPOURL and calculate MAVEN_HOME# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
if ($env:MVNW_REPOURL) {
- $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" }+ $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }- $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')"+ $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since version 3.3.0, we cannot download Maven distribution if we set MVNW_REPOURL on Windows platforms (Windows 10, Windows Server 2022) with script-only.
wrapperVersion=3.3.2 distributionType=only-script distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.z ```ip Current result (3.3.2) ``` text PS C:\workspace\poc\maven-build> .\mvnw.cmd -v icm : Exception lors de l'appel de « DownloadFile » avec « 2 » argument(s) : « Le serveur distant a retourné une erreur : (404) Introuvable. » Au caractère Ligne:1 : 72 + ... 'mvnw.cmd'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Invoke-Command], MethodInvocationException + FullyQualifiedErrorId : WebException,Microsoft.PowerShell.Commands.InvokeCommandCommand Commande ECHO activée. Cannot start maven from wrapperExpected result was
If MVNW_VERBOSE is also set to true we can have some hints
PS C:\workspace\poc\maven-build> .\mvnw.cmd -v COMMENTAIRES : Couldn't find MAVEN_HOME, downloading and installing it ... COMMENTAIRES : Downloading from: https://nexus.local/repository/maven-repo/maven/mvnd/https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip COMMENTAIRES : Downloading to: C:\Users\jahk04\AppData\Local\Temp\tmp950D.tmp.dir/apache-maven-3.9.9-bin.zip icm : Exception lors de l'appel de «DownloadFile» avec «2» argument(s): «Le serveur distant a retourné une erreur: (404) Introuvable.» Au caractère Ligne:1 : 72 + ... 'mvnw.cmd'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Invoke-Command], MethodInvocationException + FullyQualifiedErrorId : WebException,Microsoft.PowerShell.Commands.InvokeCommandCommand Commande ECHO activée. Cannot start maven from wrapper$env:MVNW_REPOURL is concatened with mvnd context and the actual distributionUrl defined inside .mvn/wrapper/maven-wrapper.properties
Looking at script mvnw.cmd, it seems that the following block is at fault with two "bugs"
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004