public class Exec extends org.gradle.api.internal.ConventionTask implements ExecSpec
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()
}
}
Task.NamerTASK_ACTION, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE| Constructor and Description |
|---|
Exec() |
| Modifier and Type | Method and Description |
|---|---|
ExecSpec |
args(Iterable<?> args)
Adds arguments for the command to be executed.
|
Exec |
args(Object... args)
Adds arguments for the command to be executed.
|
ExecSpec |
commandLine(Iterable<?> args)
Sets the full command line, including the executable to be executed plus its arguments.
|
Exec |
commandLine(Object... arguments)
Sets the full command line, including the executable to be executed plus its arguments.
|
Exec |
copyTo(ProcessForkOptions target)
Copies these options to the given target options.
|
Exec |
environment(Map<String,?> environmentVariables)
Adds some environment variables to the environment for this process.
|
Exec |
environment(String name,
Object value)
Adds an environment variable to the environment for this process.
|
Exec |
executable(Object executable)
Sets the name of the executable to use.
|
List<String> |
getArgs()
Returns the arguments for the command to be executed.
|
List<String> |
getCommandLine()
Returns the full command line, including the executable plus its arguments.
|
Map<String,Object> |
getEnvironment()
The environment variables to use for the process.
|
OutputStream |
getErrorOutput()
Returns the output stream to consume standard error from the process executing the command.
|
ExecResult |
getExecResult()
Returns the result for the command run by this task.
|
String |
getExecutable()
Returns the name of the executable to use.
|
InputStream |
getStandardInput()
Returns the standard input stream for the process executing the command.
|
OutputStream |
getStandardOutput()
Returns the output stream to consume standard output from the process executing the command.
|
File |
getWorkingDir()
Returns the working directory for the process.
|
boolean |
isIgnoreExitValue()
Tells whether a non-zero exit value is ignored, or an exception thrown.
|
Exec |
setArgs(Iterable<?> arguments)
Sets the arguments for the command to be executed.
|
void |
setCommandLine(Iterable<?> args)
Sets the full command line, including the executable to be executed plus its arguments.
|
void |
setCommandLine(Object... args)
Sets the full command line, including the executable to be executed plus its arguments.
|
void |
setEnvironment(Map<String,?> environmentVariables)
Sets the environment variable to use for the process.
|
Exec |
setErrorOutput(OutputStream outputStream)
Sets the output stream to consume standard error from the process executing the command.
|
void |
setExecutable(Object executable)
Sets the name of the executable to use.
|
ExecSpec |
setIgnoreExitValue(boolean ignoreExitValue)
Sets whether a non-zero exit value is ignored, or an exception thrown.
|
Exec |
setStandardInput(InputStream inputStream)
Sets the standard input stream for the process executing the command.
|
Exec |
setStandardOutput(OutputStream outputStream)
Sets the output stream to consume standard output from the process executing the command.
|
void |
setWorkingDir(Object dir)
Sets the working directory for the process.
|
Exec |
workingDir(Object dir)
Sets the working directory for the process.
|
conventionMapping, conventionMapping, getConventionMappingaddValidator, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, doFirst, doFirst, doLast, doLast, execute, executeWithoutThrowingTaskFailure, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDidWork, getEnabled, getExecuter, getExtensions, getGroup, getInputs, getLogger, getLogging, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getStandardOutputCapture, getState, getStateInternal, getTaskDependencies, getTemporaryDir, getTemporaryDirFactory, getValidators, hasProperty, injectIntoNewInstance, isEnabled, leftShift, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setExecuter, setGroup, setName, setOnlyIf, setOnlyIf, setProject, setProperty, toStringpublic Exec commandLine(Object... arguments)
commandLine in interface ExecSpecarguments - the command plus the args to be executedpublic ExecSpec commandLine(Iterable<?> args)
commandLine in interface ExecSpecargs - the command plus the args to be executedpublic Exec setArgs(Iterable<?> arguments)
public List<String> getArgs()
public List<String> getCommandLine()
getCommandLine in interface BaseExecSpecpublic void setCommandLine(Iterable<?> args)
setCommandLine in interface ExecSpecargs - the command plus the args to be executedpublic void setCommandLine(Object... args)
setCommandLine in interface ExecSpecargs - the command plus the args to be executedpublic String getExecutable()
getExecutable in interface ProcessForkOptionspublic void setExecutable(Object executable)
setExecutable in interface ProcessForkOptionsexecutable - The executable. Must not be null.public Exec executable(Object executable)
executable in interface ProcessForkOptionsexecutable - The executable. Must not be null.public File getWorkingDir()
getWorkingDir in interface ProcessForkOptionspublic void setWorkingDir(Object dir)
Project.file(Object).setWorkingDir in interface ProcessForkOptionsdir - The working directory. Must not be null.public Exec workingDir(Object dir)
Project.file(Object).workingDir in interface ProcessForkOptionsdir - The working directory. Must not be null.public Map<String,Object> getEnvironment()
getEnvironment in interface ProcessForkOptionspublic void setEnvironment(Map<String,?> environmentVariables)
setEnvironment in interface ProcessForkOptionsenvironmentVariables - The environment variables. Must not be null.public Exec environment(String name, Object value)
environment in interface ProcessForkOptionsname - The name of the variable.value - The value for the variable. Must not be null.public Exec environment(Map<String,?> environmentVariables)
environment in interface ProcessForkOptionsenvironmentVariables - The environment variables. Must not be null.public Exec copyTo(ProcessForkOptions target)
copyTo in interface ProcessForkOptionstarget - The target optionspublic Exec setStandardInput(InputStream inputStream)
setStandardInput in interface BaseExecSpecinputStream - The standard input stream for the process. Must not be null.public InputStream getStandardInput()
getStandardInput in interface BaseExecSpecpublic Exec setStandardOutput(OutputStream outputStream)
setStandardOutput in interface BaseExecSpecoutputStream - The standard output stream for the process. Must not be null.public OutputStream getStandardOutput()
System.out.getStandardOutput in interface BaseExecSpecpublic Exec setErrorOutput(OutputStream outputStream)
setErrorOutput in interface BaseExecSpecoutputStream - The standard output error stream for the process. Must not be null.public OutputStream getErrorOutput()
System.err.getErrorOutput in interface BaseExecSpecpublic ExecSpec setIgnoreExitValue(boolean ignoreExitValue)
setIgnoreExitValue in interface BaseExecSpecignoreExitValue - whether a non-zero exit value is ignored, or an exception thrownpublic boolean isIgnoreExitValue()
false.isIgnoreExitValue in interface BaseExecSpecpublic ExecResult getExecResult()
null if this task has not been executed yet.null if this task has not been executed yet.