public class DefaultGradle extends Object implements GradleInternal
| Constructor and Description |
|---|
DefaultGradle(Gradle parent,
StartParameter startParameter,
ServiceRegistryFactory parentRegistry) |
| Modifier and Type | Method and Description |
|---|---|
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<? super Project> 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.
|
BuildListener |
getBuildListenerBroadcaster()
Returns the broadcaster for
BuildListener events |
ProjectInternal |
getDefaultProject()
Returns the default project.
|
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.
|
ProjectEvaluationListener |
getProjectEvaluationBroadcaster()
Returns the broadcaster for
ProjectEvaluationListener events for this build |
IProjectRegistry<ProjectInternal> |
getProjectRegistry() |
ProjectInternal |
getRootProject()
Returns the root project of this build.
|
MultiParentClassLoader |
getScriptClassLoader()
Returns the root
ClassLoader to use for the scripts of this build. |
ServiceRegistryFactory |
getServices() |
StartParameter |
getStartParameter()
Returns the
StartParameter used to start this build. |
TaskGraphExecuter |
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<? super Project> action)
Adds an action to execute against the root project of this build.
|
void |
setDefaultProject(ProjectInternal defaultProject)
Called by the BuildLoader after the default project is determined.
|
void |
setRootProject(ProjectInternal rootProject)
Called by the BuildLoader after the root project is determined.
|
void |
setTaskGraph(TaskGraphExecuter taskGraph) |
void |
settingsEvaluated(Closure closure)
Adds a closure to be called when the build settings have been loaded and evaluated.
|
String |
toString() |
void |
useLogger(Object logger)
Uses the given object as a logger.
|
public DefaultGradle(Gradle parent, StartParameter startParameter, ServiceRegistryFactory parentRegistry)
public Gradle getParent()
GradleReturns the parent build of this build, if any.
public String getGradleVersion()
GradleReturns the current Gradle version.
getGradleVersion in interface Gradlepublic File getGradleHomeDir()
GradleReturns the Gradle home directory, if any. This directory is the directory containing the Gradle distribution executing this build.
getGradleHomeDir in interface Gradlepublic File getGradleUserHomeDir()
GradleReturns the Gradle user home directory. This directory is used to cache downloaded resources.
getGradleUserHomeDir in interface Gradlepublic StartParameter getStartParameter()
GradleStartParameter used to start this build.getStartParameter in interface Gradlepublic ProjectInternal getRootProject()
GradleInternalReturns the root project of this build.
getRootProject in interface GradleInternalgetRootProject in interface Gradlepublic void setRootProject(ProjectInternal rootProject)
GradleInternalGradleInternal.getRootProject() will return null.setRootProject in interface GradleInternalrootProject - The root project for this build.public void rootProject(Action<? super Project> action)
GradlerootProject in interface Gradleaction - The action to execute.public void allprojects(Action<? super Project> action)
Gradleallprojects in interface Gradleaction - The action to execute.public ProjectInternal getDefaultProject()
GradleInternalgetDefaultProject in interface GradleInternalpublic void setDefaultProject(ProjectInternal defaultProject)
GradleInternalGradleInternal.getDefaultProject() will return null.setDefaultProject in interface GradleInternaldefaultProject - The default project for this build.public TaskGraphExecuter getTaskGraph()
GradleInternalReturns the TaskExecutionGraph for this build.
getTaskGraph in interface GradleInternalgetTaskGraph in interface Gradlepublic void setTaskGraph(TaskGraphExecuter taskGraph)
public IProjectRegistry<ProjectInternal> getProjectRegistry()
getProjectRegistry in interface GradleInternalpublic MultiParentClassLoader getScriptClassLoader()
GradleInternalClassLoader to use for the scripts of this build.getScriptClassLoader in interface GradleInternalpublic ProjectEvaluationListener addProjectEvaluationListener(ProjectEvaluationListener listener)
GradleaddProjectEvaluationListener in interface Gradlelistener - The listener to add. Does nothing if this listener has already been added.public void removeProjectEvaluationListener(ProjectEvaluationListener listener)
GradleremoveProjectEvaluationListener in interface Gradlelistener - The listener to remove. Does nothing if this listener has not been added.public void beforeProject(Closure closure)
GradlebeforeProject in interface Gradleclosure - The closure to execute.public void afterProject(Closure closure)
GradleafterProject in interface Gradleclosure - The closure to execute.public void buildStarted(Closure closure)
GradleGradle instance is passed to the closure as
the first parameter.buildStarted in interface Gradleclosure - The closure to execute.public void settingsEvaluated(Closure closure)
GradleSettings object is passed to the closure as a parameter.settingsEvaluated in interface Gradleclosure - The closure to execute.public void projectsLoaded(Closure closure)
GradleGradle instance is passed to the closure as a parameter.
An example of hooking into the projectsLoaded to configure buildscript classpath from the init script.
//init.gradle
gradle.projectsLoaded {
rootProject.buildscript {
repositories {
//...
}
dependencies {
//...
}
}
}
projectsLoaded in interface Gradleclosure - The closure to execute.public void projectsEvaluated(Closure closure)
GradleGradle instance is passed to
the closure as a parameter.projectsEvaluated in interface Gradleclosure - The closure to execute.public void buildFinished(Closure closure)
GradleBuildResult instance is passed to the closure as a parameter.buildFinished in interface Gradleclosure - The closure to execute.public void addListener(Object listener)
GradleaddListener in interface Gradlelistener - The listener to add. Does nothing if this listener has already been added.public void removeListener(Object listener)
GradleremoveListener in interface Gradlelistener - The listener to remove. Does nothing if this listener has not been added.public void useLogger(Object logger)
GradleGradle.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.public ProjectEvaluationListener getProjectEvaluationBroadcaster()
GradleInternalProjectEvaluationListener events for this buildgetProjectEvaluationBroadcaster in interface GradleInternalpublic void addBuildListener(BuildListener buildListener)
GradleAdds a BuildListener to this Build instance. The listener is notified of events which occur during the
execution of the build.
addBuildListener in interface GradlebuildListener - The listener to add.public BuildListener getBuildListenerBroadcaster()
GradleInternalBuildListener eventsgetBuildListenerBroadcaster in interface GradleInternalpublic Gradle getGradle()
GradleGradle 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.public ServiceRegistryFactory getServices()
getServices in interface GradleInternalCopyright © 2013. All rights reserved