Package org.gradle.api.tasks
Class AbstractExecTask<T extends AbstractExecTask>
- java.lang.Object
-
- org.gradle.api.internal.AbstractTask
-
- org.gradle.api.DefaultTask
-
- org.gradle.api.internal.ConventionTask
-
- org.gradle.api.tasks.AbstractExecTask<T>
-
- Type Parameters:
T- The concrete type of the class.
- All Implemented Interfaces:
java.lang.Comparable<Task>,org.gradle.api.internal.DynamicObjectAware,org.gradle.api.internal.IConventionAware,org.gradle.api.internal.TaskInternal,Named,ExtensionAware,Task,BaseExecSpec,ExecSpec,ProcessForkOptions,Configurable<Task>
- Direct Known Subclasses:
Exec,RunTestExecutable
@DisableCachingByDefault(because="Abstract super-class, not to be instantiated directly") public abstract class AbstractExecTask<T extends AbstractExecTask> extends org.gradle.api.internal.ConventionTask implements ExecSpec
AbstractExecTaskis the base class for all exec tasks.
-
-
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_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
-
-
Constructor Summary
Constructors Constructor Description AbstractExecTask(java.lang.Class<T> taskType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Targs(java.lang.Iterable<?> args)Adds arguments for the command to be executed.Targs(java.lang.Object... args)Adds arguments for the command to be executed.TcommandLine(java.lang.Iterable<?> args)Sets the full command line, including the executable to be executed plus its arguments.TcommandLine(java.lang.Object... arguments)Sets the full command line, including the executable to be executed plus its arguments.TcopyTo(ProcessForkOptions target)Copies these options to the given target options.Tenvironment(java.lang.String name, java.lang.Object value)Adds an environment variable to the environment for this process.Tenvironment(java.util.Map<java.lang.String,?> environmentVariables)Adds some environment variables to the environment for this process.protected voidexec()Texecutable(java.lang.Object executable)Sets the name of the executable to use.java.util.List<java.lang.String>getArgs()Returns the arguments for the command to be executed.java.util.List<CommandLineArgumentProvider>getArgumentProviders()Argument providers for the application.java.util.List<java.lang.String>getCommandLine()Returns the full command line, including the executable plus its arguments.java.util.Map<java.lang.String,java.lang.Object>getEnvironment()The environment variables to use for the process.java.io.OutputStreamgetErrorOutput()Returns the output stream to consume standard error from the process executing the command.protected org.gradle.process.internal.ExecActionFactorygetExecActionFactory()java.lang.StringgetExecutable()Returns the name of the executable to use.Provider<ExecResult>getExecutionResult()Returns the result for the command run by this task.protected ObjectFactorygetObjectFactory()java.io.InputStreamgetStandardInput()Returns the standard input stream for the process executing the command.java.io.OutputStreamgetStandardOutput()Returns the output stream to consume standard output from the process executing the command.java.io.FilegetWorkingDir()Returns the working directory for the process.booleanisIgnoreExitValue()Tells whether a non-zero exit value is ignored, or an exception thrown.TsetArgs(java.lang.Iterable<?> arguments)Sets the arguments for the command to be executed.TsetArgs(java.util.List<java.lang.String> arguments)Sets the arguments for the command to be executed.voidsetCommandLine(java.lang.Iterable<?> args)Sets the full command line, including the executable to be executed plus its arguments.voidsetCommandLine(java.lang.Object... args)Sets the full command line, including the executable to be executed plus its arguments.voidsetCommandLine(java.util.List<java.lang.String> args)Sets the full command line, including the executable to be executed plus its arguments.voidsetEnvironment(java.util.Map<java.lang.String,?> environmentVariables)Sets the environment variable to use for the process.TsetErrorOutput(java.io.OutputStream outputStream)Sets the output stream to consume standard error from the process executing the command.voidsetExecutable(java.lang.Object executable)Sets the name of the executable to use.voidsetExecutable(java.lang.String executable)Sets the name of the executable to use.TsetIgnoreExitValue(boolean ignoreExitValue)Sets whether a non-zero exit value is ignored, or an exception thrown.TsetStandardInput(java.io.InputStream inputStream)Sets the standard input stream for the process executing the command.TsetStandardOutput(java.io.OutputStream outputStream)Sets the output stream to consume standard output from the process executing the command.voidsetWorkingDir(java.io.File dir)Sets the working directory for the process.voidsetWorkingDir(java.lang.Object dir)Sets the working directory for the process.TworkingDir(java.lang.Object dir)Sets the working directory for the process.-
Methods inherited from class org.gradle.api.internal.ConventionTask
conventionMapping, conventionMapping, getConventionMapping
-
Methods inherited from class org.gradle.api.DefaultTask
compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService
-
Methods inherited from class org.gradle.api.internal.AbstractTask
acceptServiceReferences, appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjects
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.gradle.api.Task
doNotTrackState, getConvention, notCompatibleWithConfigurationCache
-
-
-
-
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:
commandLinein interfaceExecSpec- 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:
commandLinein interfaceExecSpec- 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.
-
args
public T args(java.lang.Iterable<?> args)
Adds arguments for the command to be executed.
-
setArgs
public T setArgs(java.util.List<java.lang.String> arguments)
Sets the arguments for the command to be executed.
-
setArgs
public T setArgs(@Nullable java.lang.Iterable<?> arguments)
Sets the arguments for the command to be executed.
-
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.
-
getArgumentProviders
public java.util.List<CommandLineArgumentProvider> getArgumentProviders()
Argument providers for the application.- Specified by:
getArgumentProvidersin interfaceExecSpec
-
getCommandLine
@Internal public java.util.List<java.lang.String> getCommandLine()
Returns the full command line, including the executable plus its arguments.- Specified by:
getCommandLinein interfaceBaseExecSpec- 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:
setCommandLinein interfaceExecSpec- 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:
setCommandLinein interfaceExecSpec- 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:
setCommandLinein interfaceExecSpec- Parameters:
args- the command plus the args to be executed
-
getExecutable
@Nullable @Optional @Input public java.lang.String getExecutable()
Returns the name of the executable to use.- Specified by:
getExecutablein interfaceProcessForkOptions- Returns:
- The executable.
-
setExecutable
public void setExecutable(@Nullable java.lang.String executable)Sets the name of the executable to use.- Specified by:
setExecutablein interfaceProcessForkOptions- 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:
setExecutablein interfaceProcessForkOptions- 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:
executablein interfaceProcessForkOptions- 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:
getWorkingDirin interfaceProcessForkOptions- Returns:
- The working directory. Never returns null.
-
setWorkingDir
public void setWorkingDir(java.io.File dir)
Sets the working directory for the process.- Specified by:
setWorkingDirin interfaceProcessForkOptions- 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 perProject.file(Object).- Specified by:
setWorkingDirin interfaceProcessForkOptions- 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 perProject.file(Object).- Specified by:
workingDirin interfaceProcessForkOptions- 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:
getEnvironmentin interfaceProcessForkOptions- 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:
setEnvironmentin interfaceProcessForkOptions- 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:
environmentin interfaceProcessForkOptions- 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:
environmentin interfaceProcessForkOptions- 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:
copyToin interfaceProcessForkOptions- 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:
setStandardInputin interfaceBaseExecSpec- 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:
getStandardInputin interfaceBaseExecSpec- 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:
setStandardOutputin interfaceBaseExecSpec- 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 toSystem.out.- Specified by:
getStandardOutputin interfaceBaseExecSpec- 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:
setErrorOutputin interfaceBaseExecSpec- 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 toSystem.err.- Specified by:
getErrorOutputin interfaceBaseExecSpec- 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:
setIgnoreExitValuein interfaceBaseExecSpec- 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 tofalse.- Specified by:
isIgnoreExitValuein interfaceBaseExecSpec- 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
-
-