Model Builder
A ModelBuilder allows you to fetch a snapshot of some model for a project or a build. Instances of ModelBuilder are not thread-safe.
You use a ModelBuilder as follows:
- Create an instance of
ModelBuilderby calling model. - Configure the builder as appropriate.
- Call either get or get to build the model.
- Optionally, you can reuse the builder to build the model multiple times.
ProjectConnection connection = GradleConnector.newConnector()
.forProjectDirectory(new File("someFolder"))
.connect();
try {
ModelBuilder<GradleProject> builder = connection.model(GradleProject.class);
//configure the standard input in case your build is interactive:
builder.setStandardInput(new ByteArrayInputStream("consume this!".getBytes()));
//if you want to listen to the progress events:
ProgressListener listener = null; // use your implementation
builder.addProgressListener(listener);
//get the model:
GradleProject project = builder.get();
//query the model for information:
System.out.println("Available tasks: " + project.getTasks());
} finally {
connection.close();
}
Content copied to clipboard
Since
1.0-milestone-3
Parameters
<T>
The type of model to build
Functions
Link copied to clipboard
Appends new command line arguments to the existing list.
Link copied to clipboard
Appends Java VM arguments to the existing list.
Link copied to clipboard
Adds a progress listener which will receive progress events as the operation runs.
Adds a progress listener which will receive progress events of all types as the operation runs.
abstract fun addProgressListener(listener: ProgressListener, operationTypes: Array<OperationType>): T
abstract fun addProgressListener(listener: ProgressListener, operationTypes: Set<OperationType>): LongRunningOperation
abstract fun addProgressListener(listener: ProgressListener, operationTypes: Array<OperationType>): LongRunningOperation
Adds a progress listener which will receive progress events as the operations of the requested type run.
Link copied to clipboard
Specifies whether to generate colored (ANSI encoded) output for logging.
Link copied to clipboard
abstract fun setEnvironmentVariables(@Nullable envVariables: @Nullable Map<String, String>): LongRunningOperation
Specifies the environment variables to use for this operation.
Link copied to clipboard
Specifies the Java home directory to use for this operation.
Link copied to clipboard
abstract fun setJvmArguments(@Nullable jvmArguments: @Nullable Iterable<String>): LongRunningOperation
Specifies the Java VM arguments to use for this operation.
Link copied to clipboard
Sets the which should receive standard error logging generated while running the operation.
Sets the OutputStream which should receive standard error logging generated while running the operation.
Link copied to clipboard
Sets the that will be used as standard input for this operation.
Sets the java.io.InputStream that will be used as standard input for this operation.
Link copied to clipboard
Sets the which should receive standard output logging generated while running the operation.
Sets the java.io.OutputStream which should receive standard output logging generated while running the operation.
Link copied to clipboard
Specify the command line build arguments.
Link copied to clipboard
Sets the cancellation token to use to cancel the operation if required.
Link copied to clipboard
Adds more detailed information about the build failure to the that provides insights into the reasons for the failure, making it easier to diagnose and fix issues.
Adds more detailed information about the build failure to the GradleConnectionException that provides insights into the reasons for the failure, making it easier to diagnose and fix issues.
Link copied to clipboard
Sets system properties to pass to the build.