[ 
https://issues.apache.org/jira/browse/MWRAPPER-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17879365#comment-17879365
 ] 

ASF GitHub Bot commented on MWRAPPER-146:
-----------------------------------------

sebthom opened a new pull request, #152:
URL: https://github.com/apache/maven-wrapper/pull/152

   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) 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.
    - [X] 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.
    - [X] 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) 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)
   you have to acknowledge this by using the following check-box.
   
    - [X] 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)
   
    - [X] In any other case, please file an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   




> Bad substitution on Windows if MVNW_REPOURL is set on script-only
> -----------------------------------------------------------------
>
>                 Key: MWRAPPER-146
>                 URL: https://issues.apache.org/jira/browse/MWRAPPER-146
>             Project: Maven Wrapper
>          Issue Type: Bug
>          Components: Maven Wrapper Scripts
>    Affects Versions: 3.3.0, 3.3.1, 3.3.2
>         Environment: Windows 10, Windows Server 2022 with powershell 5.1
>            Reporter: Bruno Villegas
>            Priority: Major
>
> 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.
> {noformat}
> 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.zip{noformat}
> {noformat}
> 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{noformat}
> If MVNW_VERBOSE is  also set to "true" we can have some hints
> {noformat}
> 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{noformat}
> $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
> {code:java}
> # 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/" }
>   $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl 
> -replace '^.*'+$MVNW_REPO_PATTERN,'')"
> } {code}
> Two "bugs" in my opinion
>  - USE_MVND evaluation is incorrect: should have been 
> {code:java}
> if ($USE_MVND -eq $False){code}
>   the variable USE_MVND is previously set to either  $true or $false
>  
>  - The string substitution doesn't work correctly, the following works for my 
> environment
> {code:java}
> $($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",''){code}
> After fixing these two lines
> {noformat}
> 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
> {noformat}
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to