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

## org.gradle.api.invocation
[Java] Interface Gradle

    public interface Gradle

Represents an invocation of Gradle.

You can obtain a `Gradle` instance by calling Project#getGradle()#getGradle().

Method Summary
`void` | `addBuildListener(BuildListener buildListener)` Adds a BuildListener to this Build instance.
`void` | `addListener(java.lang.Object listener)` Adds the given listener to this build.
`ProjectEvaluationListener` | `addProjectEvaluationListener(ProjectEvaluationListener listener)` Adds a listener to this build, to receive notifications as projects are evaluated.
`void` | `afterProject(groovy.lang.Closure closure)` Adds a closure to be called immediately after a project is evaluated.
`void` | `beforeProject(groovy.lang.Closure closure)` Adds a closure to be called immediately before a project is evaluated.
`void` | `buildFinished(groovy.lang.Closure closure)` Adds a closure to be called when the build is completed.
`void` | `buildStarted(groovy.lang.Closure closure)` Adds a closure to be called when the build is started.
`Gradle` | `getGradle()` Returns this `Gradle` instance.
`java.io.File` | `getGradleHomeDir()` Returns the Gradle home directory, if any.
`java.io.File` | `getGradleUserHomeDir()` Returns the Gradle user home directory.
`java.lang.String` | `getGradleVersion()` Returns the current Gradle version.
`Gradle` | `getParent()` Returns the parent build of this build, if any.
`Project` | `getRootProject()` Returns the root project of this build.
`StartParameter` | `getStartParameter()` Returns the StartParameter used to start this build.
`TaskExecutionGraph` | `getTaskGraph()` Returns the TaskExecutionGraph for this build.
`void` | `projectsEvaluated(groovy.lang.Closure closure)` Adds a closure to be called when all projects for the build have been evaluated.
`void` | `projectsLoaded(groovy.lang.Closure closure)` Adds a closure to be called when the projects for the build have been created from the settings.
`void` | `removeListener(java.lang.Object listener)` Removes the given listener from this build.
`void` | `removeProjectEvaluationListener(ProjectEvaluationListener listener)` Removes the given listener from this build.
`void` | `settingsEvaluated(groovy.lang.Closure closure)` Adds a closure to be called when the build settings have been loaded and evaluated.
`void` | `useLogger(java.lang.Object logger)` Uses the given object as a logger.

Method Detail

### addBuildListener

    public void addBuildListener(BuildListener buildListener)

  Adds a BuildListener to this Build instance. The listener is notified of events which occur during the execution of the build.

  Parameters:
    `buildListener` - The listener to add.

### addListener

    public void addListener(java.lang.Object listener)

  Adds the given listener to this build. The listener may implement any of the given listener interfaces:
  - BuildListener
  - TaskExecutionGraphListener
  - ProjectEvaluationListener
  - TaskExecutionListener
  - TaskActionListener
  - StandardOutputListener
  - TestListener
  Parameters:
    `listener` - The listener to add. Does nothing if this listener has already been added.

### addProjectEvaluationListener

    public ProjectEvaluationListener addProjectEvaluationListener(ProjectEvaluationListener listener)

  Adds a listener to this build, to receive notifications as projects are evaluated.
  Parameters:
    `listener` - The listener to add. Does nothing if this listener has already been added.
  Returns:
    The added listener.

### afterProject

    public void afterProject(groovy.lang.Closure closure)

  Adds a closure to be called immediately after a project is evaluated. The project is passed to the closure as the first parameter. The project evaluation failure, if any, is passed as the second parameter. Both parameters are optional.
  Parameters:
    `closure` - The closure to execute.

### beforeProject

    public void beforeProject(groovy.lang.Closure closure)

  Adds a closure to be called immediately before a project is evaluated. The project is passed to the closure as a parameter.
  Parameters:
    `closure` - The closure to execute.

### buildFinished

    public void buildFinished(groovy.lang.Closure closure)

  Adds a closure to be called when the build is completed. All selected tasks have been executed. A BuildResult instance is passed to the closure as a parameter.
  Parameters:
    `closure` - The closure to execute.

### buildStarted

    public void buildStarted(groovy.lang.Closure closure)

  Adds a closure to be called when the build is started. This `Gradle` instance is passed to the closure as the first parameter.
  Parameters:
    `closure` - The closure to execute.

### getGradle

    public Gradle getGradle()

  Returns this `Gradle` instance. This method is useful in init scripts to explicitly access Gradle properties and methods. For example, using `gradle.parent` can express your intent better than using `parent`. This property also allows you to access Gradle properties from a scope where the property may be hidden, such as, for example, from a method or closure.
  Returns:
    this. Never returns null.

### getGradleHomeDir

    public java.io.File getGradleHomeDir()

  Returns the Gradle home directory, if any. This directory is the directory containing the Gradle distribution executing this build.

  deprecated:
    No replacement
  Returns:
    The home directory. May return null.

### getGradleUserHomeDir

    public java.io.File getGradleUserHomeDir()

  Returns the Gradle user home directory. This directory is used to cache downloaded resources.

  Returns:
    The user home directory. Never returns null.

### getGradleVersion

    public java.lang.String getGradleVersion()

  Returns the current Gradle version.

  Returns:
    The Gradle version. Never returns null.

### getParent

    public Gradle getParent()

  Returns the parent build of this build, if any.

  Returns:
    The parent build. May return null.

### getRootProject

    public Project getRootProject()

  Returns the root project of this build.

  Returns:
    The root project. Never returns null.

### getStartParameter

    public StartParameter getStartParameter()

  Returns the StartParameter used to start this build.
  Returns:
    The start parameter. Never returns null.

### getTaskGraph

    public TaskExecutionGraph getTaskGraph()

  Returns the TaskExecutionGraph for this build.

  Returns:
    The task graph. Never returns null.

### projectsEvaluated

    public void projectsEvaluated(groovy.lang.Closure closure)

  Adds a closure to be called when all projects for the build have been evaluated. The project objects are fully configured and are ready to use to populate the task graph. This `Gradle` instance is passed to the closure as a parameter.
  Parameters:
    `closure` - The closure to execute.

### projectsLoaded

    public void projectsLoaded(groovy.lang.Closure closure)

  Adds a closure to be called when the projects for the build have been created from the settings. None of the projects have been evaluated. This `Gradle` instance is passed to the closure as a parameter.
  Parameters:
    `closure` - The closure to execute.

### removeListener

    public void removeListener(java.lang.Object listener)

  Removes the given listener from this build.
  Parameters:
    `listener` - The listener to remove. Does nothing if this listener has not been added.

### removeProjectEvaluationListener

    public void removeProjectEvaluationListener(ProjectEvaluationListener listener)

  Removes the given listener from this build.
  Parameters:
    `listener` - The listener to remove. Does nothing if this listener has not been added.

### settingsEvaluated

    public void settingsEvaluated(groovy.lang.Closure closure)

  Adds a closure to be called when the build settings have been loaded and evaluated. The settings object is fully configured and is ready to use to load the build projects. The Settings object is passed to the closure as a parameter.
  Parameters:
    `closure` - The closure to execute.

### useLogger

    public void useLogger(java.lang.Object logger)

  Uses the given object as a logger. The logger object may implement any of the listener interfaces supported by addListener(Object). Each listener interface has exactly one associated logger. When you call this method with a logger of a given listener type, the new logger will replace whichever logger is currently associated with the listener type. This allows you to selectively replace the standard logging which Gradle provides with your own implementation, for certain types of events.
  Parameters:
    `logger` - The logger to use.

Groovy Documentation