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

## org.gradle
Class Gradle

    java.lang.Object
      org.gradle.Gradle

    class Gradle
    extends java.lang.Object

`Gradle` is the main entry point for embedding Gradle. You use this class to manage a Gradle build, as follows:

1. Create a org.gradle.StartParameter instance and configure it with the desired properties. The properties of `StartParameter` generally correspond to the command-line options of Gradle.

2. Obtain a `Gradle` instance by calling #newInstance, passing in the `StartParameter`.

3. Optionally, add one or more org.gradle.BuildListeners to receive events as the build executes by calling #addBuildListener.

4. Call #run to execute the build. This will return a org.gradle.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() to rethrow any build failure.

author:
  Hans Dockter

Nested Class Summary
`interface` | `Gradle.RunSpecification`

Constructor Summary
`Gradle(StartParameter startParameter, ISettingsFinder settingsFinder, IGradlePropertiesLoader gradlePropertiesLoader, SettingsProcessor settingsProcessor, BuildLoader buildLoader, BuildConfigurer buildConfigurer)`

Method Summary
`void` | `addBuildListener(BuildListener buildListener)` Adds a {
`static StartParameter` | `createStartParameter(java.lang.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.
`StartParameter` | `getStartParameter()`
`static void` | `injectCustomFactory(GradleFactory gradleFactory)`
`static Gradle` | `newInstance(StartParameter startParameter)` Returns a Gradle instance based on the passed start parameter.
`static Gradle` | `newInstance(java.lang.String[] commandLineArgs)` Returns a Gradle instance based on the passed command line syntax arguments.
`BuildResult` | `run()` Executes the build for this Gradle instance and returns the result.

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

Constructor Detail

### Gradle

    public Gradle(StartParameter startParameter, ISettingsFinder settingsFinder, IGradlePropertiesLoader gradlePropertiesLoader, SettingsProcessor settingsProcessor, BuildLoader buildLoader, BuildConfigurer buildConfigurer)

Method Detail

### addBuildListener

    public void addBuildListener(BuildListener buildListener)

  Adds a org.gradle.BuildListener to this Gradle instance. The listener is notified of events which occur during a build.

  param:
    buildListener The listener to add.

### createStartParameter

    public static StartParameter createStartParameter(java.lang.String[] commandLineArgs)

  Returns a StartParameter object out of command line syntax arguments. Every possible command line option has it associated field in the StartParameter object.
  param:
    commandLineArgs A String array where each element denotes an entry of the Gradle command line syntax

### getBuildAnalysis

    public BuildResult getBuildAnalysis()

  Evaluates the settings and all the projects. The information about available tasks and projects is accessible via the org.gradle.api.invocation.Build#getRootProject() object.
  return:
    A BuildResult object

### getBuildAndRunAnalysis

    public BuildResult getBuildAndRunAnalysis()

  Evaluates the settings and all the projects. Evaluates the settings and all the projects. The information about available tasks and projects is accessible via the org.gradle.api.invocation.Build#getRootProject() object. Fills the execution plan without running the build. The tasks to be executed tasks are available via org.gradle.api.invocation.Build#getTaskGraph().
  return:
    A BuildResult object

### getStartParameter

    public StartParameter getStartParameter()

### injectCustomFactory

    public static void injectCustomFactory(GradleFactory gradleFactory)

### newInstance

    public static Gradle newInstance(StartParameter startParameter)

  Returns a Gradle instance based on the passed start parameter.
  param:
    startParameter The start parameter object the Gradle instance is initialized with

### newInstance

    public static Gradle newInstance(java.lang.String[] commandLineArgs)

  Returns a Gradle instance based on the passed command line syntax arguments. Certain command line arguments won't have any effect if you choose this method (e.g. -v, -h). If you want to act upon, you better use #createStartParameter(String[]) in conjunction with #newInstance(String[]).
  param:
    commandLineArgs A String array where each element denotes an entry of the Gradle command line syntax

### run

    public BuildResult run()

  Executes the build for this Gradle instance and returns the result. Note that when the build fails, the exception is available using BuildResult#getFailure().

  return:
    The result. Never returns null.

Groovy Documentation