api / org.gradle.tooling / BuildLauncher

BuildLauncher

interface BuildLauncher : ConfigurableLauncher<BuildLauncher>

A BuildLauncher allows you to configure and execute a Gradle build.

Instances of BuildLauncher are not thread-safe. You use a BuildLauncher as follows:

Example:
 ProjectConnection connection = GradleConnector.newConnector() .forProjectDirectory(new File("someFolder")) .connect(); try { BuildLauncher build = connection.newBuild(); //select tasks to run: build.forTasks("clean", "test"); //include some build arguments: build.withArguments("-i", "--project-dir", "someProjectDir"); //configure the standard input: build.setStandardInput(new ByteArrayInputStream("consume this!".getBytes())); //in case you want the build to use java different than default: build.setJavaHome(new File("/path/to/java")); //if your build needs crazy amounts of memory: build.setJvmArguments("-Xmx2048m", "-XX:MaxPermSize=512m"); //if you want to listen to the progress events: ProgressListener listener = null; // use your implementation build.addProgressListener(listener); //kick the build off: build.run(); } finally { connection.close(); } 

Since
1.0-milestone-3

Functions

forLaunchables

abstract fun forLaunchables(vararg launchables: Launchable): BuildLauncher
abstract fun forLaunchables(launchables: MutableIterable<Launchable>): BuildLauncher

Sets the launchables to execute. If no entries are specified, the project's default tasks are executed.

forTasks

abstract fun forTasks(vararg tasks: String): BuildLauncher

Sets the tasks to be executed. If no tasks are specified, the project's default tasks are executed.

abstract fun forTasks(vararg tasks: Task): BuildLauncher
abstract fun forTasks(tasks: MutableIterable<Task>): BuildLauncher

Sets the tasks to be executed. If no tasks are specified, the project's default tasks are executed.

Note that the supplied tasks do not necessarily need to belong to the project which this launcher was created for.

run

abstract fun run(): Unit

Executes the build, blocking until it is complete.

abstract fun run(handler: ResultHandler<in Void>): Unit

Launches the build. This method returns immediately, and the result is later passed to the given handler.

If the operation fails, the handler's ResultHandler#onFailure(GradleConnectionException) method is called with the appropriate exception. See #run() for a description of the various exceptions that the operation may fail with.

Inherited Functions

addProgressListener

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}

setColorOutput

abstract fun setColorOutput(colorOutput: Boolean): T

{@inheritDoc}

setEnvironmentVariables

abstract fun setEnvironmentVariables(envVariables: MutableMap<String, String>): T

{@inheritDoc}

setJavaHome

abstract fun setJavaHome(javaHome: File): T

{@inheritDoc}

setJvmArguments

abstract fun setJvmArguments(vararg jvmArguments: String): T
abstract fun setJvmArguments(jvmArguments: MutableIterable<String>): T

{@inheritDoc}

setStandardError

abstract fun setStandardError(outputStream: OutputStream): T

{@inheritDoc}

setStandardInput

abstract fun setStandardInput(inputStream: InputStream): T

{@inheritDoc}

setStandardOutput

abstract fun setStandardOutput(outputStream: OutputStream): T

{@inheritDoc}

withArguments

abstract fun withArguments(vararg arguments: String): T
abstract fun withArguments(arguments: MutableIterable<String>): T

{@inheritDoc}

withCancellationToken

abstract fun withCancellationToken(cancellationToken: CancellationToken): T

{@inheritDoc}