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

## org.gradle
[Java] Class GradleLauncher

    java.lang.Object
      org.gradle.GradleLauncher

    @Deprecated
    public abstract class GradleLauncher

Executes a Gradle build.

`GradleLauncher` is deprecated. It has been replaced by the Tooling API. If you're interested in embedding Gradle you should read the user guide chapter on embedding Gradle. The main entry point to the Tooling API (and embedding Gradle) is `org.gradle.tooling.GradleConnector`.

You should try using the Tooling API (via `GradleConnector`) instead of `GradleLauncher`. However, if you need some capability that isn't yet implemented in the Tooling API here is how you use `GradleLauncher`:

1. Optionally create a StartParameter instance and configure it with the desired properties. The properties of `StartParameter` generally correspond to the command-line options of Gradle. You can use createStartParameter(String...) to create a StartParameter from a set of command-line options.
2. Obtain a `GradleLauncher` instance by calling newInstance, passing in the `StartParameter`, or an array of Strings that will be treated as command line arguments.
3. Optionally add one or more listeners to the `GradleLauncher`.
4. Call run to execute the build. This will return a BuildResult. Note that if the build fails, the resulting exception will be contained in the `BuildResult`.
5. Query the build result. You might want to call BuildResult#rethrowFailure()#rethrowFailure() to rethrow any build failure.

deprecated:
  Use the tooling API instead.

Method Summary
`void` | `addListener(Object listener)`
`void` | `addStandardErrorListener(StandardOutputListener listener)`
`void` | `addStandardOutputListener(StandardOutputListener listener)`
`static StartParameter` | `createStartParameter(String... commandLineArgs)` Returns a `StartParameter` object out of command line syntax arguments.
`BuildResult` | `getBuildAnalysis()` Evaluates the settings and all the projects.
`BuildResult` | `getBuildAndRunAnalysis()` Evaluates the settings and all the projects.
`static GradleLauncherFactory` | `getFactory()`
`StartParameter` | `getStartParameter()` Returns the StartParameter used by this build instance.
`static void` | `injectCustomFactory(GradleLauncherFactory gradleLauncherFactory)`
`static GradleLauncher` | `newInstance(StartParameter startParameter)` Returns a `GradleLauncher` instance based on the passed start parameter.
`static GradleLauncher` | `newInstance(String... commandLineArgs)` Returns a `GradleLauncher` instance based on the passed command line syntax arguments.
`BuildResult` | `run()`
`void` | `useLogger(Object logger)` Use the given listener.

Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Method Detail

### addListener

    public void addListener(Object listener)

  Adds a listener to this build instance. The listener is notified of events which occur during the execution of the build. See Gradle.addListener for supported listener types.

  Parameters:
    `listener` - The listener to add. Has no effect if the listener has already been added.

### addStandardErrorListener

    public void addStandardErrorListener(StandardOutputListener listener)

  Adds a StandardOutputListener to this build instance. The listener is notified of any text written to standard error by Gradle's logging system

  Parameters:
    `listener` - The listener to add. Has no effect if the listener has already been added.

### addStandardOutputListener

    public void addStandardOutputListener(StandardOutputListener listener)

  Adds a StandardOutputListener to this build instance. The listener is notified of any text written to standard output by Gradle's logging system

  Parameters:
    `listener` - The listener to add. Has no effect if the listener has already been added.

### createStartParameter

    @Deprecated
    public static StartParameter createStartParameter(String... commandLineArgs)

  Returns a `StartParameter` object out of command line syntax arguments. Each command line option has an associated field in the `StartParameter` object.
  deprecated:
    No replacement.
  Parameters:
    `commandLineArgs` - A String array where each element denotes an entry of the Gradle command line syntax
  Returns:
    The `GradleLauncher`. Never returns null.

### getBuildAnalysis

    public BuildResult getBuildAnalysis()

  Evaluates the settings and all the projects. The information about available tasks and projects is accessible via the Gradle.getRootProject object.
  Returns:
    The result. Never returns null.

### getBuildAndRunAnalysis

    public BuildResult getBuildAndRunAnalysis()

  Evaluates the settings and all the projects. The information about available tasks and projects is accessible via the Gradle.getRootProject object. Fills the execution plan without running the build. The tasks to be executed tasks are available via Gradle.getTaskGraph.
  Returns:
    The result. Never returns null.

### getFactory

    @Deprecated
    public static GradleLauncherFactory getFactory()

### getStartParameter

    public StartParameter getStartParameter()

  Returns the StartParameter used by this build instance.
  Returns:
    The parameter. Never null.

### injectCustomFactory

    @Deprecated
    public static void injectCustomFactory(GradleLauncherFactory gradleLauncherFactory)

### newInstance

    @Deprecated
    public static GradleLauncher newInstance(StartParameter startParameter)

  Returns a `GradleLauncher` instance based on the passed start parameter.
  deprecated:
    Use the tooling API instead.
  Parameters:
    `startParameter` - The start parameter object the GradleLauncher instance is initialized with
  Returns:
    The `GradleLauncher`. Never returns null.

### newInstance

    @Deprecated
    public static GradleLauncher newInstance(String... commandLineArgs)

  Returns a `GradleLauncher` instance based on the passed command line syntax arguments.
  deprecated:
    Use the tooling API instead.
  Parameters:
    `commandLineArgs` - A String array where each element denotes an entry of the Gradle command line syntax
  Returns:
    The `GradleLauncher`. Never returns null.

### run

    public BuildResult run()

  Executes the build for this `GradleLauncher` instance and returns the result. Note that when the build fails, the exception is available using BuildResult.getFailure.

  Returns:
    The result. Never returns null.

### useLogger

    public void useLogger(Object logger)

  Use the given listener. See Gradle.useLogger for details.
  Parameters:
    `logger` - The logger to use.

Gradle API 1.10