|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD |
org.gradle.api.plugins.PluginAware org.gradle.api.invocation.Gradle
@HasInternalProtocol public interface Gradle extends PluginAware
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(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(Closure closure)
Adds a closure to be called immediately after a project is evaluated. |
void
|
allprojects(Action action)
Adds an action to execute against all projects of this build. |
void
|
beforeProject(Closure closure)
Adds a closure to be called immediately before a project is evaluated. |
void
|
buildFinished(Closure closure)
Adds a closure to be called when the build is completed. |
void
|
buildStarted(Closure closure)
Adds a closure to be called when the build is started. |
Gradle
|
getGradle()
Returns this Gradle instance. |
File
|
getGradleHomeDir()
Returns the Gradle home directory, if any. |
File
|
getGradleUserHomeDir()
Returns the Gradle user home directory. |
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(Closure closure)
Adds a closure to be called when all projects for the build have been evaluated. |
void
|
projectsLoaded(Closure closure)
Adds a closure to be called when the projects for the build have been created from the settings. |
void
|
removeListener(Object listener)
Removes the given listener from this build. |
void
|
removeProjectEvaluationListener(ProjectEvaluationListener listener)
Removes the given listener from this build. |
void
|
rootProject(Action action)
Adds an action to execute against the root project of this build. |
void
|
settingsEvaluated(Closure closure)
Adds a closure to be called when the build settings have been loaded and evaluated. |
void
|
useLogger(Object logger)
Uses the given object as a logger. |
Methods inherited from interface PluginAware | |
---|---|
apply, apply, getPlugins |
Method Detail |
---|
public void addBuildListener(BuildListener buildListener)
buildListener
- The listener to add.
public void addListener(Object listener)
listener
- The listener to add. Does nothing if this listener has already been added.
public ProjectEvaluationListener addProjectEvaluationListener(ProjectEvaluationListener listener)
listener
- The listener to add. Does nothing if this listener has already been added.
public void afterProject(Closure closure)
closure
- The closure to execute.
public void allprojects(Action action)
action
- The action to execute.
public void beforeProject(Closure closure)
closure
- The closure to execute.
public void buildFinished(Closure closure)
closure
- The closure to execute.
public void buildStarted(Closure closure)
closure
- The closure to execute.
public Gradle getGradle()
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.
public File getGradleHomeDir()
When using the “Gradle Daemon”, this may not be the same Gradle distribution that the build was started with. If an existing daemon process is running that is deemed compatible (e.g. has the desired JVM characteristics) then this daemon may be used instead of starting a new process and it may have been started from a different “gradle home”. However, it is guaranteed to be the same version of Gradle. For more information on the Gradle Daemon, please consult the user guide.
public File getGradleUserHomeDir()
public String getGradleVersion()
public Gradle getParent()
public Project getRootProject()
public StartParameter getStartParameter()
public TaskExecutionGraph getTaskGraph()
public void projectsEvaluated(Closure closure)
closure
- The closure to execute.
public void projectsLoaded(Closure closure)
An example of hooking into the projectsLoaded to configure buildscript classpath from the init script.
//init.gradle gradle.projectsLoaded { rootProject.buildscript { repositories { //... } dependencies { //... } } }
closure
- The closure to execute.
public void removeListener(Object listener)
listener
- The listener to remove. Does nothing if this listener has not been added.
public void removeProjectEvaluationListener(ProjectEvaluationListener listener)
listener
- The listener to remove. Does nothing if this listener has not been added.
public void rootProject(Action action)
action
- The action to execute.
public void settingsEvaluated(Closure closure)
closure
- The closure to execute.
public void useLogger(Object logger)
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.
logger
- The logger to use.
Gradle API 1.12