mvnw.cmd for demo spring-boot project not working in windows
Asked Answered
A

2

6

I generated a simple demo project (2.3.0 version) from Spring Initializr to my windows 8.1 OS and below is the basic structure

C:.
└───src
    ├───main
    │   ├───java
    │   │   └───com
    │   │       └───example
    │   │           └───demo
    │   └───resources
    └───test
        └───java
            └───com
                └───example
                    └───demo

I tried running mvnw.cmd clean and getting bellow error:

C:\Users\Downloads\demo\demo>mvnw.cmd clean
"}" was unexpected at this time.

Below is the same output in powershell

PS C:\Users\Downloads\demo\demo> .\mvnw.cmd clean
"}" was unexpected at this time.
PS C:\Users\Downloads\demo\demo>

I see the issue is occurring in following lines within mvnw.cmd file :

powershell -Command "&{"^
    "$webclient = new-object System.Net.WebClient;"^
    "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
    "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
    "}"^
    "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
    "}"

Not sure if i am missing anything.

Alasdair answered 26/5, 2020 at 17:59 Comment(8)
Did you run this in cmd or powershell? Try to run it in powershellEvvie
yes i tried in cmd and powershell and was getting the same errorAlasdair
Try to use a different version of mvnwEvvie
@Alasdair did you find a solution to this?Kilkenny
@ValentinDespa Not yet but strangely i see this issue only on my machine. I did try the same in another machine and worked fine.Alasdair
I have this error only in the Jenkins workspace folder. I have opened a bug report here: issues.apache.org/jira/projects/MWRAPPER/issues/MWRAPPER-4Kilkenny
issue issues.apache.org/jira/browse/MWRAPPER-48 opened: please contact us hereRapp
Happens to me with Maven 3.8.4, generated wrapper with 3.1.0 version. ``` Edition Windows 10 Enterprise Version 20H2 Installed on ‎2/‎28/‎2022 OS build 19042.1526 Experience Windows Feature Experience Pack 120.2212.4170.0 ```Greenock
S
0

I've just had the same problem, error in both cmd and powershell. Simply copying the project to an alternative directory solved the problem.

Im on windows 10, the project was originally in my downloads directory. I moved this into documents.

Sam answered 6/1, 2022 at 6:32 Comment(0)
M
0

Testes and i worked on this path: C:\tmp\New (2){6} folder\my-app57(2). The problem is the ')' character.

My solution is:

@setlocal EnableDelayedExpansion
    powershell -Command "&{"^
          "$webclient = new-object System.Net.WebClient;"^
          "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
          "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
          "}"^
          "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '!WRAPPER_JAR!')"^
          "}"
@endlocal

https://issues.apache.org/jira/browse/MWRAPPER-76

Marciamarciano answered 7/9, 2022 at 13:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.