Class AbstractLongRunningOperation<T extends AbstractLongRunningOperation<T>>
- java.lang.Object
-
- org.gradle.tooling.internal.consumer.AbstractLongRunningOperation<T>
-
- All Implemented Interfaces:
LongRunningOperation
- Direct Known Subclasses:
DefaultBuildLauncher,DefaultModelBuilder,DefaultPhasedBuildActionExecuter,DefaultTestLauncher
public abstract class AbstractLongRunningOperation<T extends AbstractLongRunningOperation<T>> extends java.lang.Object implements LongRunningOperation
-
-
Field Summary
Fields Modifier and Type Field Description protected ConnectionParametersconnectionParametersprotected ConsumerOperationParameters.BuilderoperationParamsBuilder
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractLongRunningOperation(ConnectionParameters parameters)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TaddArguments(java.lang.Iterable<java.lang.String> arguments)Appends new command line arguments to the existing list.TaddArguments(java.lang.String... arguments)Appends new command line arguments to the existing list.TaddJvmArguments(java.lang.Iterable<java.lang.String> jvmArguments)Appends Java VM arguments to the existing list.TaddJvmArguments(java.lang.String... jvmArguments)Appends Java VM arguments to the existing list.TaddProgressListener(ProgressListener listener)Adds a progress listener which will receive progress events of all types as the operation runs.TaddProgressListener(ProgressListener listener, java.util.Set<OperationType> eventTypes)Adds a progress listener which will receive progress events as the operations of the requested type run.TaddProgressListener(ProgressListener listener, OperationType... operationTypes)Adds a progress listener which will receive progress events as the operations of the requested type run.TaddProgressListener(ProgressListener listener)Adds a progress listener which will receive progress events as the operation runs.voidcopyFrom(ConsumerOperationParameters operationParameters)protected ConsumerOperationParametersgetConsumerOperationParameters()protected abstract TgetThis()protected static <T> java.util.List<T>rationalizeInput(java.lang.Iterable<? extends T> arguments)protected static <T> java.util.List<T>rationalizeInput(T[] arguments)TsetColorOutput(boolean colorOutput)Specifies whether to generate colored (ANSI encoded) output for logging.TsetEnvironmentVariables(java.util.Map<java.lang.String,java.lang.String> envVariables)Specifies the environment variables to use for this operation.TsetJavaHome(java.io.File javaHome)Specifies the Java home directory to use for this operation.TsetJvmArguments(java.lang.Iterable<java.lang.String> jvmArguments)Specifies the Java VM arguments to use for this operation.TsetJvmArguments(java.lang.String... jvmArguments)Specifies the Java VM arguments to use for this operation.TsetStandardError(java.io.OutputStream outputStream)Sets theOutputStreamwhich should receive standard error logging generated while running the operation.TsetStandardInput(java.io.InputStream inputStream)Sets theInputStreamthat will be used as standard input for this operation.TsetStandardOutput(java.io.OutputStream outputStream)Sets theOutputStreamwhich should receive standard output logging generated while running the operation.TwithArguments(java.lang.Iterable<java.lang.String> arguments)Specify the command line build arguments.TwithArguments(java.lang.String... arguments)Specify the command line build arguments.TwithCancellationToken(CancellationToken cancellationToken)Sets the cancellation token to use to cancel the operation if required.TwithInjectedClassPath(org.gradle.internal.classpath.ClassPath classpath)Specifies classpath URIs used for loading user-defined classes.
-
-
-
Field Detail
-
connectionParameters
protected final ConnectionParameters connectionParameters
-
operationParamsBuilder
protected final ConsumerOperationParameters.Builder operationParamsBuilder
-
-
Constructor Detail
-
AbstractLongRunningOperation
protected AbstractLongRunningOperation(ConnectionParameters parameters)
-
-
Method Detail
-
getThis
protected abstract T getThis()
-
getConsumerOperationParameters
protected final ConsumerOperationParameters getConsumerOperationParameters()
-
rationalizeInput
@Nullable protected static <T> java.util.List<T> rationalizeInput(@Nullable T[] arguments)
-
rationalizeInput
@Nullable protected static <T> java.util.List<T> rationalizeInput(@Nullable java.lang.Iterable<? extends T> arguments)
-
withArguments
public T withArguments(java.lang.String... arguments)
Description copied from interface:LongRunningOperationSpecify the command line build arguments. Useful mostly for running tasks viaBuildLauncher.Be aware that not all of the Gradle command line options are supported! Only the build arguments that configure the build execution are supported. They are modelled in the Gradle API via
StartParameter. Examples of supported build arguments: '--info', '-p'. The command line instructions that are actually separate commands (like '-?' and '-v') are not supported. Some other instructions like '--daemon' are also not supported - the tooling API always runs with the daemon.If an unknown or unsupported command line option is specified,
UnsupportedBuildArgumentExceptionwill be thrown at the time the operation is executed viaBuildLauncher.run()orModelBuilder.get().For the list of all Gradle command line options please refer to the User Manual or take a look at the output of the 'gradle -?' command. Majority of arguments modeled by
StartParameterare supported.The arguments can potentially override some other settings you have configured. For example, the project directory or Gradle user home directory that are configured in the
GradleConnector. Also, the task names configured byBuildLauncher.forTasks(String...)can be overridden if you happen to specify other tasks via the build arguments.See the example in the docs for
BuildLauncherIf not configured, null, or an empty array is passed, then the reasonable default will be used.Requires Gradle 1.0 or later.
- Specified by:
withArgumentsin interfaceLongRunningOperation- Parameters:
arguments- Gradle command line arguments- Returns:
- this
-
withArguments
public T withArguments(java.lang.Iterable<java.lang.String> arguments)
Description copied from interface:LongRunningOperationSpecify the command line build arguments. Useful mostly for running tasks viaBuildLauncher.If not configured, null, or an empty list is passed, then the reasonable default will be used.
Requires Gradle 1.0 or later.
- Specified by:
withArgumentsin interfaceLongRunningOperation- Parameters:
arguments- Gradle command line arguments- Returns:
- this
-
addArguments
public T addArguments(java.lang.String... arguments)
Description copied from interface:LongRunningOperationAppends new command line arguments to the existing list. Useful mostly for running tasks viaBuildLauncher.- Specified by:
addArgumentsin interfaceLongRunningOperation- Parameters:
arguments- Gradle command line arguments- Returns:
- this
-
addArguments
public T addArguments(java.lang.Iterable<java.lang.String> arguments)
Description copied from interface:LongRunningOperationAppends new command line arguments to the existing list. Useful mostly for running tasks viaBuildLauncher.- Specified by:
addArgumentsin interfaceLongRunningOperation- Parameters:
arguments- Gradle command line arguments- Returns:
- this
-
setStandardOutput
public T setStandardOutput(java.io.OutputStream outputStream)
Description copied from interface:LongRunningOperationSets theOutputStreamwhich should receive standard output logging generated while running the operation. The default is to discard the output.- Specified by:
setStandardOutputin interfaceLongRunningOperation- Parameters:
outputStream- The output stream. The system default character encoding will be used to encode characters written to this stream.- Returns:
- this
-
setStandardError
public T setStandardError(java.io.OutputStream outputStream)
Description copied from interface:LongRunningOperationSets theOutputStreamwhich should receive standard error logging generated while running the operation. The default is to discard the output.- Specified by:
setStandardErrorin interfaceLongRunningOperation- Parameters:
outputStream- The output stream. The system default character encoding will be used to encode characters written to this stream.- Returns:
- this
-
setStandardInput
public T setStandardInput(java.io.InputStream inputStream)
Description copied from interface:LongRunningOperationSets theInputStreamthat will be used as standard input for this operation. Defaults to an empty input stream.- Specified by:
setStandardInputin interfaceLongRunningOperation- Parameters:
inputStream- The input stream- Returns:
- this
-
setColorOutput
public T setColorOutput(boolean colorOutput)
Description copied from interface:LongRunningOperationSpecifies whether to generate colored (ANSI encoded) output for logging. The default is to not generate color output.Supported by Gradle 2.3 or later. Ignored for older versions.
- Specified by:
setColorOutputin interfaceLongRunningOperation- Parameters:
colorOutput-trueto request color output (using ANSI encoding).- Returns:
- this
-
setJavaHome
public T setJavaHome(java.io.File javaHome)
Description copied from interface:LongRunningOperationSpecifies the Java home directory to use for this operation.BuildEnvironmentmodel contains information such as Java or Gradle environment. If you want to get hold of this information you can ask tooling API to build this model.If not configured or null is passed, then the sensible default will be used.
- Specified by:
setJavaHomein interfaceLongRunningOperation- Parameters:
javaHome- to use for the Gradle process- Returns:
- this
-
setJvmArguments
public T setJvmArguments(java.lang.String... jvmArguments)
Description copied from interface:LongRunningOperationSpecifies the Java VM arguments to use for this operation.BuildEnvironmentmodel contains information such as Java or Gradle environment. If you want to get hold of this information you can ask tooling API to build this model.If not configured, null, or an empty array is passed, then the reasonable default will be used.
- Specified by:
setJvmArgumentsin interfaceLongRunningOperation- Parameters:
jvmArguments- to use for the Gradle process- Returns:
- this
-
addJvmArguments
public T addJvmArguments(java.lang.String... jvmArguments)
Description copied from interface:LongRunningOperationAppends Java VM arguments to the existing list.- Specified by:
addJvmArgumentsin interfaceLongRunningOperation- Parameters:
jvmArguments- the argument to use for the Gradle process- Returns:
- this
-
addJvmArguments
public T addJvmArguments(java.lang.Iterable<java.lang.String> jvmArguments)
Description copied from interface:LongRunningOperationAppends Java VM arguments to the existing list.- Specified by:
addJvmArgumentsin interfaceLongRunningOperation- Parameters:
jvmArguments- the argument to use for the Gradle process- Returns:
- this
-
setJvmArguments
public T setJvmArguments(java.lang.Iterable<java.lang.String> jvmArguments)
Description copied from interface:LongRunningOperationSpecifies the Java VM arguments to use for this operation.BuildEnvironmentmodel contains information such as Java or Gradle environment. If you want to get hold of this information you can ask tooling API to build this model.If not configured, null, or an empty list is passed, then the reasonable default will be used.
- Specified by:
setJvmArgumentsin interfaceLongRunningOperation- Parameters:
jvmArguments- to use for the Gradle process- Returns:
- this
-
setEnvironmentVariables
public T setEnvironmentVariables(java.util.Map<java.lang.String,java.lang.String> envVariables)
Description copied from interface:LongRunningOperationSpecifies the environment variables to use for this operation.BuildEnvironmentmodel contains information such as Java or Gradle environment. If you want to get hold of this information you can ask tooling API to build this model.If not configured or null is passed, then the reasonable default will be used.
- Specified by:
setEnvironmentVariablesin interfaceLongRunningOperation- Parameters:
envVariables- environment variables- Returns:
- this
-
addProgressListener
public T addProgressListener(ProgressListener listener)
Description copied from interface:LongRunningOperationAdds a progress listener which will receive progress events as the operation runs.This method is intended to be replaced by
LongRunningOperation.addProgressListener(org.gradle.tooling.events.ProgressListener). The new progress listener type provides much richer information and much better handling of parallel operations that run during the build, such as tasks that run in parallel. You should prefer using the new listener interface where possible. Note, however, that the new interface is supported only for Gradle 2.5.- Specified by:
addProgressListenerin interfaceLongRunningOperation- Parameters:
listener- The listener- Returns:
- this
-
addProgressListener
public T addProgressListener(ProgressListener listener)
Description copied from interface:LongRunningOperationAdds a progress listener which will receive progress events of all types as the operation runs.This method is intended to replace
LongRunningOperation.addProgressListener(ProgressListener). You should prefer using the new progress listener method where possible, as the new interface provides much richer information and much better handling of parallel operations that run during the build.Supported by Gradle 2.5 or later. Gradle 2.4 supports
OperationType.TESToperations only. Ignored for older versions.- Specified by:
addProgressListenerin interfaceLongRunningOperation- Parameters:
listener- The listener- Returns:
- this
-
addProgressListener
public T addProgressListener(ProgressListener listener, OperationType... operationTypes)
Description copied from interface:LongRunningOperationAdds a progress listener which will receive progress events as the operations of the requested type run.This method is intended to replace
LongRunningOperation.addProgressListener(ProgressListener). You should prefer using the new progress listener method where possible, as the new interface provides much richer information and much better handling of parallel operations that run during the build.Supported by Gradle 2.5 or later. Gradle 2.4 supports
OperationType.TESToperations only. Ignored for older versions.- Specified by:
addProgressListenerin interfaceLongRunningOperation- Parameters:
listener- The listeneroperationTypes- The types of operations to receive progress events for.- Returns:
- this
-
addProgressListener
public T addProgressListener(ProgressListener listener, java.util.Set<OperationType> eventTypes)
Description copied from interface:LongRunningOperationAdds a progress listener which will receive progress events as the operations of the requested type run.This method is intended to replace
LongRunningOperation.addProgressListener(ProgressListener). You should prefer using the new progress listener method where possible, as the new interface provides much richer information and much better handling of parallel operations that run during the build.Supported by Gradle 2.5 or later. Gradle 2.4 supports
OperationType.TESToperations only. Ignored for older versions.- Specified by:
addProgressListenerin interfaceLongRunningOperation- Parameters:
listener- The listenereventTypes- The types of operations to receive progress events for.- Returns:
- this
-
withCancellationToken
public T withCancellationToken(CancellationToken cancellationToken)
Description copied from interface:LongRunningOperationSets the cancellation token to use to cancel the operation if required.Supported by Gradle 2.1 or later. Ignored for older versions.
- Specified by:
withCancellationTokenin interfaceLongRunningOperation
-
withInjectedClassPath
public T withInjectedClassPath(org.gradle.internal.classpath.ClassPath classpath)
Specifies classpath URIs used for loading user-defined classes. This list is in addition to the default classpath.- Parameters:
classpath- Classpath URIs- Returns:
- this
- Since:
- 2.8
-
copyFrom
public void copyFrom(ConsumerOperationParameters operationParameters)
-
-