Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD

## org.gradle.tooling
[Java] Interface BuildLauncher

    org.gradle.tooling.LongRunningOperation
      org.gradle.tooling.BuildLauncher

All Superinterfaces:
  LongRunningOperation

    public interface BuildLauncher
    extends LongRunningOperation

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

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

- Create an instance of `BuildLauncher` by calling ProjectConnection.newBuild.
- Configure the launcher as appropriate.
- Call either run() or run(ResultHandler) to execute the build.
- Optionally, you can reuse the launcher to launch additional builds.

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("--no-search-upward", "-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();
     }

Method Summary
`BuildLauncher` | `addProgressListener(ProgressListener listener)` {@inheritDoc}
`BuildLauncher` | `forTasks(String... tasks)` Sets the tasks to be executed.
`BuildLauncher` | `forTasks(Task... tasks)` Sets the tasks to be executed.
`BuildLauncher` | `forTasks(Iterable tasks)` Sets the tasks to be executed.
`void` | `run()` Executes the build, blocking until it is complete.
`void` | `run(ResultHandler handler)` Launches the build.
`BuildLauncher` | `setJavaHome(File javaHome)` {@inheritDoc}
`BuildLauncher` | `setJvmArguments(String... jvmArguments)` {@inheritDoc}
`BuildLauncher` | `setStandardError(OutputStream outputStream)` {@inheritDoc}
`BuildLauncher` | `setStandardInput(InputStream inputStream)` {@inheritDoc}
`BuildLauncher` | `setStandardOutput(OutputStream outputStream)` {@inheritDoc}
`BuildLauncher` | `withArguments(String... arguments)` {@inheritDoc}

Methods inherited from interface LongRunningOperation
addProgressListener, setJavaHome, setJvmArguments, setStandardError, setStandardInput, setStandardOutput, withArguments

Method Detail

### addProgressListener

    public BuildLauncher addProgressListener(ProgressListener listener)

  {@inheritDoc}

### forTasks

    public BuildLauncher forTasks(String... tasks)

  Sets the tasks to be executed.
  Parameters:
    `tasks` - The paths of the tasks to be executed. Relative paths are evaluated relative to the project for which this launcher was created.
  Returns:
    this

### forTasks

    public BuildLauncher forTasks(Task... tasks)

  Sets the tasks to be executed. Note that the supplied tasks do not necessarily belong to the project which this launcher was created for.
  Parameters:
    `tasks` - The tasks to be executed.
  Returns:
    this

### forTasks

    public BuildLauncher forTasks(Iterable tasks)

  Sets the tasks to be executed. Note that the supplied tasks do not necessarily belong to the project which this launcher was created for.
  Parameters:
    `tasks` - The tasks to be executed.
  Returns:
    this

### run

    public void run()

  Executes the build, blocking until it is complete.
  throws:
    UnsupportedVersionException When the target Gradle version does not support the features required for this build.
  throws:
    org.gradle.tooling.exceptions.UnsupportedOperationConfigurationException when you have configured the long running operation with a settings like: setStandardInput(java.io.InputStream), setJavaHome(java.io.File), setJvmArguments(String...) but those settings are not supported on the target Gradle.
  throws:
    BuildException On some failure executing the Gradle build.
  throws:
    GradleConnectionException On some other failure using the connection.
  throws:
    UnsupportedBuildArgumentException When there is a problem with build arguments provided by withArguments(String...)
  throws:
    IllegalStateException When the connection has been closed or is closing.

### run

    public void run(ResultHandler handler)

  Launches the build. This method returns immediately, and the result is later passed to the given handler.
  throws:
    IllegalStateException When the connection has been closed or is closing.
  Parameters:
    `handler` - The handler to supply the result to.

### setJavaHome

    public BuildLauncher setJavaHome(File javaHome)

  {@inheritDoc}

### setJvmArguments

    public BuildLauncher setJvmArguments(String... jvmArguments)

  {@inheritDoc}

### setStandardError

    public BuildLauncher setStandardError(OutputStream outputStream)

  {@inheritDoc}

### setStandardInput

    public BuildLauncher setStandardInput(InputStream inputStream)

  {@inheritDoc}

### setStandardOutput

    public BuildLauncher setStandardOutput(OutputStream outputStream)

  {@inheritDoc}

### withArguments

    public BuildLauncher withArguments(String... arguments)

  {@inheritDoc}

Gradle API 1.1-rc-1