Class AbstractExecTask<T extends AbstractExecTask>

    • Constructor Detail

      • AbstractExecTask

        public AbstractExecTask​(java.lang.Class<T> taskType)
    • Method Detail

      • getObjectFactory

        @Inject
        protected ObjectFactory getObjectFactory()
      • getExecActionFactory

        @Inject
        protected org.gradle.process.internal.ExecActionFactory getExecActionFactory()
      • exec

        protected void exec()
      • commandLine

        public T commandLine​(java.lang.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 T commandLine​(java.lang.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 T args​(java.lang.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 T args​(java.lang.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 T setArgs​(java.util.List<java.lang.String> arguments)
        Sets the arguments for the command to be executed.
        Specified by:
        setArgs in interface ExecSpec
        Parameters:
        arguments - args for the command
        Returns:
        this
      • setArgs

        public T setArgs​(@Nullable
                         java.lang.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

        @Nullable
        @Optional
        @Input
        public java.util.List<java.lang.String> getArgs()
        Returns the arguments for the command to be executed. Defaults to an empty list.
        Specified by:
        getArgs in interface ExecSpec
      • getCommandLine

        @Internal
        public java.util.List<java.lang.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​(java.util.List<java.lang.String> 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​(java.lang.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​(java.lang.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
      • setExecutable

        public void setExecutable​(@Nullable
                                  java.lang.String executable)
        Sets the name of the executable to use.
        Specified by:
        setExecutable in interface ProcessForkOptions
        Parameters:
        executable - The executable. Must not be null.
      • setExecutable

        public void setExecutable​(java.lang.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 T executable​(java.lang.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

        @Internal
        public java.io.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​(java.io.File dir)
        Sets the working directory for the process.
        Specified by:
        setWorkingDir in interface ProcessForkOptions
        Parameters:
        dir - The working directory. Must not be null.
      • setWorkingDir

        public void setWorkingDir​(java.lang.Object dir)
        Sets the working directory for the process. The supplied argument is evaluated as per Project.file(Object).
        Specified by:
        setWorkingDir in interface ProcessForkOptions
        Parameters:
        dir - The working directory. Must not be null.
      • workingDir

        public T workingDir​(java.lang.Object dir)
        Sets the working directory for the process. The supplied argument is evaluated as per Project.file(Object).
        Specified by:
        workingDir in interface ProcessForkOptions
        Parameters:
        dir - The working directory. Must not be null.
        Returns:
        this
      • getEnvironment

        @Internal
        public java.util.Map<java.lang.String,​java.lang.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​(java.util.Map<java.lang.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 T environment​(java.lang.String name,
                             java.lang.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 T environment​(java.util.Map<java.lang.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 T 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 T setStandardInput​(java.io.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

        @Internal
        public java.io.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 T setStandardOutput​(java.io.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

        @Internal
        public java.io.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 T setErrorOutput​(java.io.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

        @Internal
        public java.io.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 T 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

        @Input
        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
      • getExecutionResult

        @Internal
        public Provider<ExecResult> getExecutionResult()
        Returns the result for the command run by this task. The provider has no value if this task has not been executed yet.
        Returns:
        A provider of the result.
        Since:
        6.1