我正在尝试从命令行构建我们的网络项目,但跳过测试。我正在使用命令mvn clean install -Dmaven.test.skip=true
。
当我从传统的 black & 运行命令时白色命令提示符(又名 DOS shell)该命令可以工作,但是当我从“Windows PowerShell”的命令运行它时,出现以下错误:
[错误]未知的生命周期阶段“.test.skip=true”。您必须以 : 或 :[:]: 格式指定有效的生命周期阶段或目标。可用的生命周期阶段有:验证、初始化、生成源、流程源、生成资源、流程资源、
编译,处理类,生成测试源,处理测试源,生成测试资源,处理测试资源,测试编译,处理测试类,测试,准备
电子包、打包、集成测试前、集成测试、集成测试后、验证、安装、部署、站点前、站点、站点后、站点部署、清理前、清理、后干净的。 -> [帮助1]`
是什么导致了这种差异?如何让 PowerShell 表现得像传统命令提示符一样?
这是在 Windows 7 上运行的。
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
.
When I run the command from the traditional black & white Command Prompt (aka DOS shell) the command works, but when I run it from the command from "Windows PowerShell" I get the following error:
[ERROR] Unknown lifecycle phase ".test.skip=true". You must specify a valid lifecycle phase or a goal in the format : or :[:]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources,
compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepar
e-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean. -> [Help 1]`
What is causing this discrepancy and how do I get PowerShell to behave like the traditional Command Prompt?
This is running on Windows 7.
发布评论
评论(4)
根据 此电子邮件线程:
According to this email thread:
以下内容对我有用。
看起来 -D 是一种特殊字符,需要转义。
另请注意,-X 工作正常并且不需要转义。
注意替换命令中单引号的使用,如果使用双引号(即“)则需要使用``。
我在Windows 7上使用Powershell 2.0(2.0.1.1)
The following works for me.
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
在 PowerShell 中,连字符 (-) 不会被视为 Linux 终端,因此您需要在每个连字符之前使用这个 (`) 对其进行转义。
例如:-
以下命令将不起作用在 PowerShell 中
您需要在连字符 (-) 之前添加此 (`),如下所示
In the PowerShell the hyphen (-) will not be consider as linux terminals, so you need to escape it using this (`) before each hyphen.
For example:-
Below command will not work in PowerShell
Instead of this you need to add this (`) before hyphen (-) like below
当您遇到 PowerShell 对传递给控制台 EXE 的参数的解释问题时,请尝试使用 PowerShell 社区扩展。使用此工具,您可以查看 PowerShell 如何向 EXE 提供参数,例如:
简短回答 - 使用引用
'-Dmaven.test.skip=true'
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.:Short answer - use quoting
'-Dmaven.test.skip=true'