| API文档: | Exec |
|---|
执行命令行进程。例子:
task stopTomcat(type:Exec) {
workingDir '../tomcat/bin'
//on windows:
commandLine 'cmd', '/c', 'stop.bat'
//on linux
commandLine './stop.sh'
//store the output instead of printing to the console:
standardOutput = new ByteArrayOutputStream()
//extension method stopTomcat.output() can be used to obtain the output:
ext.output = {
return standardOutput.toString()
}
}
| 财产 | 描述 |
args | 要执行的命令的参数。默认为空列表。 |
argumentProviders | 应用程序的参数提供者。 |
commandLine | 完整的命令行,包括可执行文件及其参数。 |
environment | 用于进程的环境变量。默认为该进程的环境。 |
errorOutput | 用于消耗执行命令的进程中的标准错误的输出流。默认为 |
executable | 要使用的可执行文件的名称。 |
executionResult | 此任务运行的命令的结果。如果该任务尚未执行,则提供者没有任何价值。 |
ignoreExitValue | 指示是否忽略非零退出值或引发异常。默认为 |
standardInput | 执行命令的进程的标准输入流。进程完成后流将关闭。默认为空流。 |
standardOutput | 用于使用执行命令的进程的标准输出的输出流。默认为 |
workingDir | 进程的工作目录。默认为项目目录。 |
| 方法 | 描述 |
args(args) | 添加要执行的命令的参数。 |
args(args) | 添加要执行的命令的参数。 |
commandLine(args) | 设置完整的命令行,包括要执行的可执行文件及其参数。 |
commandLine(arguments) | 设置完整的命令行,包括要执行的可执行文件及其参数。 |
environment(name, value) | 向此进程的环境添加环境变量。 |
environment(environmentVariables) | 为此过程的环境添加一些环境变量。 |
executable(executable) | 设置要使用的可执行文件的名称。 |
workingDir(dir) | 设置进程的工作目录。提供的参数根据 进行评估 |
List<CommandLineArgumentProvider> argumentProviders(只读)
List<CommandLineArgumentProvider>应用程序的参数提供者。
OutputStream errorOutput
用于消耗执行命令的进程中的标准错误的输出流。默认为System.err.
String executable
要使用的可执行文件的名称。
Provider<ExecResult> executionResult
Provider<ExecResult>此任务运行的命令的结果。如果该任务尚未执行,则提供者没有任何价值。
InputStream standardInput
执行命令的进程的标准输入流。进程完成后流将关闭。默认为空流。
OutputStream standardOutput
用于使用执行命令的进程的标准输出的输出流。默认为System.out.
File workingDir
进程的工作目录。默认为项目目录。