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

前端 未结 3 1758
广开言路
广开言路 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:47

    The following works for me.

    $mvnArgs1 ="mvn test -X -Dmaven.test.skip=true".replace('-D','`-D')
    Invoke-Expression $mvnArgs1
    

    It looks like the -D is a kind of a special character and requires escaping.
    Note also that –X works fine and does not require escaping. Note the use of single quote in the replace command, if you use double quotes (i.e. ") you need to use ``.

    I am using Powershell 2.0 (2.0.1.1) on windows 7

提交回复
热议问题