Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.gradle.api.tasks
Class Exec

    java.lang.Object
      org.gradle.api.internal.AbstractTask
          org.gradle.api.DefaultTask
              org.gradle.api.internal.ConventionTask
                  org.gradle.api.tasks.Exec

All Implemented Interfaces:
  Comparable<Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, Task, BaseExecSpec, ExecSpec, ProcessForkOptions, org.gradle.util.Configurable<Task>

    public class Exec

extends org.gradle.api.internal.ConventionTask
implements ExecSpec

Executes a command line process. Example:

     task stopTomcat(type:Exec) {
       workingDir '../tomcat/bin'

       //on windows:
       commandLine 'cmd', '/c', 'stop.bat'

       //on linux (oh yeah!!!)
       commandLine './stop.sh'
     }

Nested Class Summary

Nested classes/interfaces inherited from interface org.gradle.api.Task
`Task.Namer`

Field Summary

Fields inherited from interface org.gradle.api.Task
`TASK_ACTION, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE`

Constructor Summary
`Exec()`

Method Summary
`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.

Methods inherited from class org.gradle.api.internal.ConventionTask
`conventionMapping, getConventionMapping, setConventionMapping`

Methods inherited from class org.gradle.api.internal.AbstractTask
`addValidator, captureStandardOutput, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, disableStandardOutputCapture, doFirst, doFirst, doLast, doLast, execute, executeWithoutThrowingTaskFailure, getActions, getAdditionalProperties, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDidWork, getDynamicObjectHelper, getEnabled, getExecuter, getExtensions, getGroup, getInputs, getLogger, getLogging, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getStandardOutputCapture, getState, getTaskDependencies, getTemporaryDir, getValidators, hasProperty, injectIntoNewInstance, isEnabled, leftShift, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setExecuter, setGroup, setName, setOnlyIf, setOnlyIf, setProject, setProperty, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Exec

    public Exec()

Method Detail

### commandLine

    public Exec commandLine(Object... arguments)

  Sets the full command line, including the executable to be executed plus its arguments.

  Specified by:
    `commandLine` in interface `ExecSpec`
  Parameters:
    `arguments` - the command plus the args to be executed
  Returns:
    this

### commandLine

    public ExecSpec commandLine(Iterable<?> args)

  Sets the full command line, including the executable to be executed plus its arguments.

  Specified by:
    `commandLine` in interface `ExecSpec`
  Parameters:
    `args` - the command plus the args to be executed
  Returns:
    this

### args

    public Exec args(Object... args)

  Adds arguments for the command to be executed.

  Specified by:
    `args` in interface `ExecSpec`
  Parameters:
    `args` - args for the command
  Returns:
    this

### args

    public ExecSpec args(Iterable<?> args)

  Adds arguments for the command to be executed.

  Specified by:
    `args` in interface `ExecSpec`
  Parameters:
    `args` - args for the command
  Returns:
    this

### setArgs

    public Exec setArgs(Iterable<?> arguments)

  Sets the arguments for the command to be executed.

  Specified by:
    `setArgs` in interface `ExecSpec`
  Parameters:
    `arguments` - args for the command
  Returns:
    this

### getArgs

    public List<String> getArgs()

  Returns the arguments for the command to be executed. Defaults to an empty list.

  Specified by:
    `getArgs` in interface `ExecSpec`

### getCommandLine

    public List<String> getCommandLine()

  Returns the full command line, including the executable plus its arguments.

  Specified by:
    `getCommandLine` in interface `BaseExecSpec`
  Returns:
    The full command line, including the executable plus its arguments

### setCommandLine

    public void setCommandLine(Iterable<?> args)

  Sets the full command line, including the executable to be executed plus its arguments.

  Specified by:
    `setCommandLine` in interface `ExecSpec`
  Parameters:
    `args` - the command plus the args to be executed

### setCommandLine

    public void setCommandLine(Object... args)

  Sets the full command line, including the executable to be executed plus its arguments.

  Specified by:
    `setCommandLine` in interface `ExecSpec`
  Parameters:
    `args` - the command plus the args to be executed

### getExecutable

    public String getExecutable()

  Returns the name of the executable to use.

  Specified by:
    `getExecutable` in interface `ProcessForkOptions`
  Returns:
    The executable.

### setExecutable

    public void setExecutable(Object executable)

  Sets the name of the executable to use.

  Specified by:
    `setExecutable` in interface `ProcessForkOptions`
  Parameters:
    `executable` - The executable. Must not be null.

### executable

    public Exec executable(Object executable)

  Sets the name of the executable to use.

  Specified by:
    `executable` in interface `ProcessForkOptions`
  Parameters:
    `executable` - The executable. Must not be null.
  Returns:
    this

### getWorkingDir

    public File getWorkingDir()

  Returns the working directory for the process. Defaults to the project directory.

  Specified by:
    `getWorkingDir` in interface `ProcessForkOptions`
  Returns:
    The working directory. Never returns null.

### setWorkingDir

    public void setWorkingDir(Object dir)

  Sets the working directory for the process. The supplied argument is evaluated as for `Project.file(Object)`.

  Specified by:
    `setWorkingDir` in interface `ProcessForkOptions`
  Parameters:
    `dir` - The working directory. Must not be null.

### workingDir

    public Exec workingDir(Object dir)

  Sets the working directory for the process. The supplied argument is evaluated as for `Project.file(Object)`.

  Specified by:
    `workingDir` in interface `ProcessForkOptions`
  Parameters:
    `dir` - The working directory. Must not be null.
  Returns:
    this

### getEnvironment

    public Map<String,Object> getEnvironment()

  The environment variables to use for the process. Defaults to the environment of this process.

  Specified by:
    `getEnvironment` in interface `ProcessForkOptions`
  Returns:
    The environment. Returns an empty map when there are no environment variables.

### setEnvironment

    public void setEnvironment(Map<String,?> environmentVariables)

  Sets the environment variable to use for the process.

  Specified by:
    `setEnvironment` in interface `ProcessForkOptions`
  Parameters:
    `environmentVariables` - The environment variables. Must not be null.

### environment

    public Exec environment(String name,
                            Object value)

  Adds an environment variable to the environment for this process.

  Specified by:
    `environment` in interface `ProcessForkOptions`
  Parameters:
    `name` - The name of the variable.
    `value` - The value for the variable. Must not be null.
  Returns:
    this

### environment

    public Exec environment(Map<String,?> environmentVariables)

  Adds some environment variables to the environment for this process.

  Specified by:
    `environment` in interface `ProcessForkOptions`
  Parameters:
    `environmentVariables` - The environment variables. Must not be null.
  Returns:
    this

### copyTo

    public Exec copyTo(ProcessForkOptions target)

  Copies these options to the given target options.

  Specified by:
    `copyTo` in interface `ProcessForkOptions`
  Parameters:
    `target` - The target options
  Returns:
    this

### setStandardInput

    public Exec setStandardInput(InputStream inputStream)

  Sets the standard input stream for the process executing the command. The stream is closed after the process completes.

  Specified by:
    `setStandardInput` in interface `BaseExecSpec`
  Parameters:
    `inputStream` - The standard input stream for the process. Must not be null.
  Returns:
    this

### getStandardInput

    public InputStream getStandardInput()

  Returns the standard input stream for the process executing the command. The stream is closed after the process completes. Defaults to an empty stream.

  Specified by:
    `getStandardInput` in interface `BaseExecSpec`
  Returns:
    The standard input stream.

### setStandardOutput

    public Exec setStandardOutput(OutputStream outputStream)

  Sets the output stream to consume standard output from the process executing the command. The stream is closed after the process completes.

  Specified by:
    `setStandardOutput` in interface `BaseExecSpec`
  Parameters:
    `outputStream` - The standard output stream for the process. Must not be null.
  Returns:
    this

### getStandardOutput

    public OutputStream getStandardOutput()

  Returns the output stream to consume standard output from the process executing the command. Defaults to `System.out`.

  Specified by:
    `getStandardOutput` in interface `BaseExecSpec`
  Returns:
    The output stream

### setErrorOutput

    public Exec setErrorOutput(OutputStream outputStream)

  Sets the output stream to consume standard error from the process executing the command. The stream is closed after the process completes.

  Specified by:
    `setErrorOutput` in interface `BaseExecSpec`
  Parameters:
    `outputStream` - The standard output error stream for the process. Must not be null.
  Returns:
    this

### getErrorOutput

    public OutputStream getErrorOutput()

  Returns the output stream to consume standard error from the process executing the command. Default to `System.err`.

  Specified by:
    `getErrorOutput` in interface `BaseExecSpec`
  Returns:
    The error output stream.

### setIgnoreExitValue

    public ExecSpec setIgnoreExitValue(boolean ignoreExitValue)

  Sets whether a non-zero exit value is ignored, or an exception thrown.

  Specified by:
    `setIgnoreExitValue` in interface `BaseExecSpec`
  Parameters:
    `ignoreExitValue` - whether a non-zero exit value is ignored, or an exception thrown
  Returns:
    this

### isIgnoreExitValue

    public boolean isIgnoreExitValue()

  Tells whether a non-zero exit value is ignored, or an exception thrown. Defaults to `false`.

  Specified by:
    `isIgnoreExitValue` in interface `BaseExecSpec`
  Returns:
    whether a non-zero exit value is ignored, or an exception thrown

### getExecResult

    public ExecResult getExecResult()

  Returns the result for the command run by this task. Returns `null` if this task has not been executed yet.

  Returns:
    The result. Returns `null` if this task has not been executed yet.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD