Groovy Documentation

org.gradle.tooling
[Java] Interface LongRunningOperation


public interface LongRunningOperation

Offers ways to communicate both ways with a gradle operation, be it building a model or running tasks.

Enables tracking progress via listeners that will receive events from the gradle operation.

Allows providing standard output streams that will receive output if the gradle operation writes to standard streams.

Allows providing standard input that can be consumed by the gradle operation (useful for interactive builds).

Enables configuring the build run / model request with options like the java home or jvm arguments. Those settings might not be supported by the target Gradle version. Refer to javadoc for those methods to understand what kind of exception throw and when is it thrown.


Method Summary
LongRunningOperation addProgressListener(ProgressListener listener)

Adds a progress listener which will receive progress events as the operation runs.

LongRunningOperation setJavaHome(File javaHome)

If the target gradle version supports it you can use this setting to specify the java home directory to use for the long running operation.

LongRunningOperation setJvmArguments(String... jvmArguments)

If the target gradle version supports it you can use this setting to specify the java vm arguments to use for the long running operation.

LongRunningOperation setStandardError(OutputStream outputStream)

Sets the OutputStream which should receive standard error logging generated while running the operation.

LongRunningOperation setStandardInput(InputStream inputStream)

If the target gradle version supports it you can use this setting to set the standard InputStream that will be used by builds.

LongRunningOperation setStandardOutput(OutputStream outputStream)

Sets the OutputStream which should receive standard output logging generated while running the operation.

LongRunningOperation withArguments(String... arguments)

Specify the command line build arguments.

 

Method Detail

addProgressListener

public LongRunningOperation addProgressListener(ProgressListener listener)
Adds a progress listener which will receive progress events as the operation runs.
Parameters:
listener - The listener
Returns:
this


setJavaHome

public LongRunningOperation setJavaHome(File javaHome)
If the target gradle version supports it you can use this setting to specify the java home directory to use for the long running operation.

If the target gradle version does not support it the long running operation will fail eagerly with UnsupportedOperationConfigurationException when the operation is started.

BuildEnvironment model 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 passed the sensible default will be used.

throws:
IllegalArgumentException when supplied javaHome is not a valid folder.
Parameters:
javaHome - to use for the gradle process
Returns:
this
Since:
1.0-milestone-8


setJvmArguments

public LongRunningOperation setJvmArguments(String... jvmArguments)
If the target gradle version supports it you can use this setting to specify the java vm arguments to use for the long running operation.

If the target gradle version does not support it the long running operation will fail eagerly with UnsupportedOperationConfigurationException when the operation is started.

BuildEnvironment model 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 an empty array passed then the reasonable default will be used.

Parameters:
jvmArguments - to use for the gradle process
Returns:
this
Since:
1.0-milestone-9


setStandardError

public LongRunningOperation setStandardError(OutputStream outputStream)
Sets the OutputStream which should receive standard error logging generated while running the operation. The default is to discard the output.
Parameters:
outputStream - The output stream.
Returns:
this


setStandardInput

public LongRunningOperation setStandardInput(InputStream inputStream)
If the target gradle version supports it you can use this setting to set the standard InputStream that will be used by builds. Useful when the tooling api drives interactive builds.

If the target gradle version does not support it the long running operation will fail eagerly with UnsupportedOperationConfigurationException when the operation is started.

If not configured or null passed the dummy input stream with zero bytes is used to avoid the build hanging problems.

Parameters:
inputStream - The input stream
Returns:
this
Since:
1.0-milestone-8


setStandardOutput

public LongRunningOperation setStandardOutput(OutputStream outputStream)
Sets the OutputStream which should receive standard output logging generated while running the operation. The default is to discard the output.
Parameters:
outputStream - The output stream.
Returns:
this


withArguments

public LongRunningOperation withArguments(String... arguments)
Specify the command line build arguments. Useful mostly for running tasks via BuildLauncher.

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', '-u', '-p'. The command line instructions that are actually separate commands (like '-?', '-v') are not supported. Some other instructions like '--daemon' are also not supported - the tooling API always runs with the daemon.

If you specify unknown or unsupported command line option the UnsupportedBuildArgumentException will be thrown but only at the time when you execute the operation, i.e. BuildLauncher#run()#run() or ModelBuilder#get()#get().

For the list of all Gradle command line options please refer to the user guide or take a look at the output of the 'gradle -?' command. Supported arguments are those modelled by StartParameter.

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 by BuildLauncher.forTasks can be overridden if you happen to specify other tasks via the build arguments.

See the example in the docs for BuildLauncher

Parameters:
arguments - gradle command line arguments
Returns:
this
Since:
1.0-rc-1


 

Gradle API 1.0