interface ModelBuilder<T : Any> : ConfigurableLauncher<ModelBuilder<T>>
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:
ModelBuilder
by calling org.gradle.tooling.ProjectConnection#model(Class)
. #get()
or #get(ResultHandler)
to build the model. ProjectConnection connection = GradleConnector.newConnector() .forProjectDirectory(new File("someFolder")) .connect(); try { ModelBuilder<GradleProject> builder = connection.model(GradleProject.class); //if you use a different than usual build file name: builder.withArguments("--build-file", "theBuild.gradle"); //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(); }
Since
1.0-milestone-3
abstract fun forTasks(vararg tasks: String): ModelBuilder<T> abstract fun forTasks(tasks: MutableIterable<String>): ModelBuilder<T>
Specifies the tasks to execute before building the model. If not configured, null, or an empty array is passed, then no tasks will be executed. |
|
abstract fun get(): T
Fetch the model, blocking until it is available. abstract fun get(handler: ResultHandler<in T>): Unit
Starts fetching the model, passing the result to the given handler when complete. This method returns immediately, and the result is later passed to the given handler's If the operation fails, the handler's |
abstract fun addProgressListener(listener: ProgressListener): T abstract fun addProgressListener(listener: ProgressListener): T abstract fun addProgressListener(listener: ProgressListener, eventTypes: MutableSet<OperationType>): T abstract fun addProgressListener(listener: ProgressListener, vararg operationTypes: OperationType): T
{@inheritDoc} |
|
abstract fun setColorOutput(colorOutput: Boolean): T
{@inheritDoc} |
|
abstract fun setEnvironmentVariables(envVariables: MutableMap<String, String>): T
{@inheritDoc} |
|
abstract fun setJavaHome(javaHome: File): T
{@inheritDoc} |
|
abstract fun setJvmArguments(vararg jvmArguments: String): T abstract fun setJvmArguments(jvmArguments: MutableIterable<String>): T
{@inheritDoc} |
|
abstract fun setStandardError(outputStream: OutputStream): T
{@inheritDoc} |
|
abstract fun setStandardInput(inputStream: InputStream): T
{@inheritDoc} |
|
abstract fun setStandardOutput(outputStream: OutputStream): T
{@inheritDoc} |
|
abstract fun withArguments(vararg arguments: String): T abstract fun withArguments(arguments: MutableIterable<String>): T
{@inheritDoc} |
|
abstract fun withCancellationToken(cancellationToken: CancellationToken): T
{@inheritDoc} |