5

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.

Sachin
  • 2,087
  • 16
  • 22

2 Answers2

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.

PowerMan2015
  • 1,307
  • 5
  • 19
  • 40
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

Svein
  • 1
  • 2