org.gradle.api.invocation
Interface Gradle


public interface Gradle

A Gradle represents an invocation of Gradle.

You can obtain a Gradle instance by calling Project.getGradle(). In your build file you can use gradle to access it.


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 captureStandardOutput(LogLevel level)
          Starts redirection of standard output during to the logging system during init script evaluation.
 void disableStandardOutputCapture()
          Disables redirection of standard output during init script evaluation.
 Gradle getGradle()
          Returns this Gradle instance.
 java.io.File getGradleHomeDir()
          Returns the Gradle home directory.
 java.io.File getGradleUserHomeDir()
          Returns the Gradle user home directory.
 java.lang.String getGradleVersion()
          Returns the current Gradle version.
 ScriptHandler getInitscript()
          Returns the init script handler for this build.
 InternalRepository getInternalRepository()
          Returns the repository used to pass artifacts between projects in this build.
 Logger getLogger()
          Returns the logger for this build.
 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 initscript(groovy.lang.Closure configureClosure)
          Configures the init script classpath for this build.
 void removeListener(java.lang.Object listener)
          Removes the given listener from this build.
 void removeProjectEvaluationListener(ProjectEvaluationListener listener)
          Removes the given listener from this build.
 

Method Detail

getGradleVersion

java.lang.String getGradleVersion()

Returns the current Gradle version.

Returns:
The Gradle version. Never returns null.

getGradleUserHomeDir

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.

getGradleHomeDir

java.io.File getGradleHomeDir()

Returns the Gradle home directory. This directory is used to locate resources such as the default imports file.

Returns:
The home directory. Never returns null.

getRootProject

Project getRootProject()

Returns the root project of this build.

Returns:
The root project. Never returns null.

getTaskGraph

TaskExecutionGraph getTaskGraph()

Returns the TaskExecutionGraph for this build.

Returns:
The task graph. Never returns null.

getStartParameter

StartParameter getStartParameter()
Returns the StartParameter used to start this build.

Returns:
The start parameter. Never returns null.

getInternalRepository

InternalRepository getInternalRepository()
Returns the repository used to pass artifacts between projects in this build.

Returns:
The internal repository. Never returns null.

addProjectEvaluationListener

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.

removeProjectEvaluationListener

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.

beforeProject

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.

afterProject

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 options.

Parameters:
closure - The closure to execute.

addBuildListener

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

void addListener(java.lang.Object listener)
Adds the given listener to this build.

Parameters:
listener - The listener to add. Does nothing if this listener has already been added.

removeListener

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.

getGradle

Gradle getGradle()
Returns this Gradle instance.

Returns:
this. Never returns null.

getInitscript

ScriptHandler getInitscript()
Returns the init script handler for this build. You can use this handler to manage the classpath used to compile and execute the build's init scripts.

Returns:
the classpath handler. Never returns null.

initscript

void initscript(groovy.lang.Closure configureClosure)
Configures the init script classpath for this build. The given closure is executed against this build's ScriptHandler. The ScriptHandler is passed to the closure as the closure's delegate.

Parameters:
configureClosure - the closure to use to configure the init script classpath.

disableStandardOutputCapture

void disableStandardOutputCapture()
Disables redirection of standard output during init script evaluation. By default redirection is enabled.

See Also:
captureStandardOutput(org.gradle.api.logging.LogLevel)

captureStandardOutput

void captureStandardOutput(LogLevel level)
Starts redirection of standard output during to the logging system during init script evaluation. By default redirection is enabled and the output is redirected to the QUIET level. System.err is always redirected to the ERROR level. Redirection of output at execution time can be configured via the tasks. For more fine-grained control on redirecting standard output see StandardOutputLogging.

Parameters:
level - The level standard out should be logged to.
See Also:
disableStandardOutputCapture()

getLogger

Logger getLogger()
Returns the logger for this build. You can use this in your init scripts to write log messages.

Returns:
The logger. Never returns null.