Cannot run Maven using `mvn -D` argument within Microsoft Powershell, but works in Command Prompt

前端 未结 3 1745
广开言路
广开言路 2020-12-02 13:16

I am trying to build our web project from the commandline but skipping the testing. I am using the command mvn clean install -Dmaven.test.skip=true.

Whe

3条回答
  •  醉梦人生
    2020-12-02 13:54

    When you run into problems with PowerShell's interpretation of arguments to be passed to a console EXE, try using the echoargs.exe utility that comes with the PowerShell Community Extensions. With this tool you can see how PowerShell supplies the arguments to the EXE e.g.:

    PS> echoargs mvn clean install -Dmaven.test.skip=true
    Arg 0 is 
    Arg 1 is 
    Arg 2 is 
    Arg 3 is <-Dmaven>
    Arg 4 is <.test.skip=true>
    
    PS> echoargs mvn clean install '-Dmaven.test.skip=true'
    Arg 0 is 
    Arg 1 is 
    Arg 2 is 
    Arg 3 is <-Dmaven.test.skip=true>
    

    Short answer - use quoting '-Dmaven.test.skip=true'

提交回复
热议问题