|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Project
This interface is the main API you use to interact with Gradle from your build file. From a Project, you
can programmatically access all Gradle's features.
There is a one-to-one relationship between a Project and a "build.gradle"
file. During build initialisation, Gradle assembles a Project object for each project which is to
participate in the build, as follows:
Settings instance for the build."settings.gradle" script, if
present, against the Settings object to configure it.Settings object to create the hierarchy of Project instances.Project by executing its "build.gradle" file, if
present, against the project. The project are evaulated in breadth-wise order, such that a project is evaulated
before its child projects. This order can be overridden by adding an evaluation dependency.
A project is essentially a collection of Task objects. Each task performs some basic piece of work, such
as compiling classes, or running unit tests, or zipping up a WAR file. You add tasks to a project using one of the
createTask(String) methods. You can locate existing tasks using one of the task(String)
methods.
A project generally has a number of dependencies it needs in order to do its work. Also, a project generally
produces a number of artifacts, which other projects can use. You use the DependencyManager returned by
getDependencies() method to manage the dependencies and artifacts of the project.
Projects are arranged into a hierarchy of projects. A project has a name, and a fully qualified path which uniquely identifies it in the hierarchy.
Gradle executes the project's build file against the Project instance to configure the project. Any
property or method which your script uses which is not defined in the script is delegated through to the associated
Project object. This means, that you can use any of the methods and properties on the
Project interface directly in your script.
For example:
createTask('some-task') // Delegates to Project.createTask()
reportDir = file('reports') // Delegates to Project.file() and Project.setProperty()
You can also access the Project instance using the project property. This can make the
script clearer in some cases. For example, you could use project.name rather than name to
access the project's name.
A project has 5 property 'scopes', which it searches for properties. You can access these properties by name in
your build file, or by calling the project's property(String) method. The scopes are:
Project object itself. This scope includes any property getters and setters declared by the
Project implementation class. For example, getRootProject() is accessable as the
rootProject property. The properties of this scope are readable or writable depending on the presence
of the corresponding getter or setter method.Plugin applied to the project. A Plugin can add properties and methods to a project through the project's Convention object. The properties
of this scope may be readable or writable, depending on the convention objects.compile is accessable as the compile
property.When reading a property, the project searches the above scopes in order, and returns the value from the first
scope it finds the property in. See property(String) for more details.
When writing a property, the project searches the above scopes in order, and sets the property in the first scope
it finds the property in. If not found, the project adds the property to its map of additional properties. See
setProperty(String, Object) for more details.
A project has 5 method 'scopes', which it searches for methods:
Project object itself.Plugin applied to the project. A Plugin can add properties and method to a project through the project's Convention object.Task.configure(groovy.lang.Closure) method for the
associated task with the provided closure. For example, if the project has a task called compile, then a
method is added with the following signature: void compile(Closure configureClosure).
| Field Summary | |
|---|---|
static java.lang.String |
CACHE_DIR_NAME
|
static java.lang.String |
DEFAULT_ARCHIVES_TASK_BASE_NAME
|
static java.lang.String |
DEFAULT_BUILD_DIR_NAME
The default build directory name. |
static java.lang.String |
DEFAULT_BUILD_FILE
The default project build file name. |
static java.lang.String |
EMBEDDED_SCRIPT_ID
|
static java.lang.String |
GRADLE_PROPERTIES
|
static java.lang.String |
PATH_SEPARATOR
The hierarchy separator for project and task path names |
static java.lang.String |
SYSTEM_PROP_PREFIX
|
static java.lang.String |
TMP_DIR_NAME
|
| Method Summary | |
|---|---|
java.lang.String |
absolutePath(java.lang.String path)
Converts a name to an absolute project path, resolving names relative to this project. |
AfterEvaluateListener |
addAfterEvaluateListener(AfterEvaluateListener afterEvaluateListener)
Adds an AfterEvaluateListener to this project. |
void |
addAfterEvaluateListener(groovy.lang.Closure afterEvaluateListener)
Adds the given closure as an AfterEvaluateListener. |
void |
allprojects(groovy.lang.Closure configureClosure)
Executes the given closure against this project and its subprojects. |
void |
allprojects(ProjectAction action)
Executes the given ProjectAction against this project and its subprojects. |
groovy.util.AntBuilder |
ant(groovy.lang.Closure configureClosure)
Executes the given closure against the AntBuilder for this project. |
void |
applyActions(java.util.Set<Project> projects,
ProjectAction action)
|
void |
captureStandardOutput(LogLevel level)
Starts redirection of standard output during to the logging system during project evaluation. |
Project |
childrenDependOnMe()
Declares that all child projects of this project have an execution dependency on this project. |
java.lang.Object |
configure(java.lang.Object object,
groovy.lang.Closure configureClosure)
Allows to configure an object via an closure. |
groovy.util.AntBuilder |
createAntBuilder()
Creates and additional AntBuilder for this project. |
Task |
createTask(java.util.Map<java.lang.String,?> args,
java.lang.String name)
Creates a Task with the given name and adds it to this project. |
Task |
createTask(java.util.Map<java.lang.String,?> args,
java.lang.String name,
groovy.lang.Closure action)
Creates a Task with the given name and adds it to this project. |
Task |
createTask(java.util.Map<java.lang.String,?> args,
java.lang.String name,
TaskAction action)
Creates a Task with the given name and adds it to this project. |
Task |
createTask(java.lang.String name)
Creates a Task with the given name and adds it to this project. |
Task |
createTask(java.lang.String name,
groovy.lang.Closure action)
Creates a Task with the given name and adds it to this project. |
Task |
createTask(java.lang.String name,
TaskAction action)
Creates a Task with the given name and adds it to this project. |
void |
defaultTasks(java.lang.String... defaultTasks)
Sets the names of the default tasks of this project. |
DependencyManager |
dependencies(groovy.lang.Closure configureClosure)
Executes the given closure against the DependencyManager for this project. |
void |
dependsOn(java.lang.String path)
Declares that this project has an execution dependency on the project with the given path. |
void |
dependsOn(java.lang.String path,
boolean evaluateDependsOnProject)
Declares that this project has an execution dependency on the project with the given path. |
Project |
dependsOnChildren()
Declares that this project have an execution dependency on each of its child projects. |
Project |
dependsOnChildren(boolean evaluateDependsOnProject)
Declares that this project have an execution dependency on each of its child projects. |
int |
depthCompare(Project otherProject)
Compares the nesting level of this project with another project of the multi-project hierarchy. |
void |
disableStandardOutputCapture()
Disables redirection of standard output during project evaluation. |
Project |
evaluationDependsOn(java.lang.String path)
Declares that this project has an evaulation dependency on the project with the given path. |
java.io.File |
file(java.lang.Object path)
Resolves a file path relative to the project directory of this project. |
java.io.File |
file(java.lang.Object path,
PathValidation validation)
Resolves a file path relative to the project directory of this project and validates it using the given scheme. |
Project |
findProject(java.lang.String path)
Locates a project by path. |
Task |
findTask(java.lang.String path)
Locates a Task by path. |
java.util.List<AfterEvaluateListener> |
getAfterEvaluateListeners()
Returns all AfterEvaluateListeners of this project. |
java.util.Set<Project> |
getAllprojects()
Returns the set containing this project and its subprojects. |
java.util.Map<Project,java.util.Set<Task>> |
getAllTasks(boolean recursive)
Returns a map of the tasks contained in this project, and optionally its subprojects. |
groovy.util.AntBuilder |
getAnt()
Returns the AntBuilder for this project. |
java.util.Set<java.lang.Class<? extends Plugin>> |
getAppliedPlugins()
Returns the set of plugin types which have been applied to this project. |
java.lang.String |
getArchivesBaseName()
Returns the default prefix for naming archives generated by bundle archive tasks. |
java.lang.String |
getArchivesTaskBaseName()
Returns the default prefix for naming archive tasks created via Bundle
tasks. |
Build |
getBuild()
Returns the Build which this project belongs to. |
java.io.File |
getBuildDir()
Returns the build directory of this project. |
java.lang.String |
getBuildDirName()
Returns the name of the build directory of this project. |
java.lang.String |
getBuildFileClassName()
Returns the name of the classname the build file compiles to. |
java.lang.String |
getBuildFileName()
Returns the name of the build file Gradle tries to apply against this project object. |
java.util.Map<java.lang.String,Project> |
getChildProjects()
Returns the direct children of this project. |
Convention |
getConvention()
Return the Convention for this project. |
java.util.List<java.lang.String> |
getDefaultTasks()
Returns the names of the default tasks of this project. |
DependencyManager |
getDependencies()
Return the DependencyManager for this project. |
java.util.Set<Project> |
getDependsOnProjects()
Returns the set of projects which this project depends on. |
int |
getDepth()
Returns the nesting level of a project in a multi-project hierarchy. |
java.lang.String |
getGradleUserHome()
Returns the home directory for a Gradle user. |
org.slf4j.Logger |
getLogger()
Returns the logger for this project. |
java.lang.String |
getName()
Returns the name of this project. |
Project |
getParent()
Returns the parent project of this project, if any. |
java.lang.String |
getPath()
Returns the path of this project. |
Project |
getProject()
Returns this project. |
java.io.File |
getProjectDir()
The directory containing the project build file. |
java.util.Map<java.lang.String,?> |
getProperties()
Returns the properties of this project. |
java.io.File |
getRootDir()
Returns the root directory of this project. |
Project |
getRootProject()
Returns the root project for the hierarchy that this project belongs to. |
java.util.Set<Project> |
getSubprojects()
Returns the set containing the subprojects of this project. |
java.util.Map<java.lang.String,Task> |
getTasks()
Returns the tasks of this project. |
java.util.Set<Task> |
getTasksByName(java.lang.String name,
boolean recursive)
Returns the set of tasks with the given name contained in this project, and optionally its subprojects. |
boolean |
hasProperty(java.lang.String propertyName)
Determines if this project has the given property. |
Project |
project(java.lang.String path)
Locates a project by path. |
Project |
project(java.lang.String path,
groovy.lang.Closure configureClosure)
Locates a project by path and configures it using the given closure. |
java.lang.Object |
property(java.lang.String propertyName)
Returns the value of the given property. |
java.io.File |
relativePath(java.lang.Object path)
Returns a file object with a relative path to the project directory. |
void |
setArchivesBaseName(java.lang.String archivesBaseName)
The default prefix for naming the archives generated by archive task. |
void |
setArchivesTaskBaseName(java.lang.String archivesTaskBaseName)
Sets the default prefix used for naming archive tasks. |
void |
setBuildDirName(java.lang.String buildDirName)
Sets the build directory name of this project. |
void |
setDefaultTasks(java.util.List<java.lang.String> defaultTasks)
Sets the names of the default tasks of this project. |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Sets a property of this project. |
void |
subprojects(groovy.lang.Closure configureClosure)
Executes the given closure against each of the subprojects of this project. |
void |
subprojects(ProjectAction action)
Executes the given ProjectAction against the subprojects of this project. |
Task |
task(java.lang.String path)
Returns the Task from the project which has the given path. |
Task |
task(java.lang.String path,
groovy.lang.Closure configurationClosure)
Returns the Task from this project which has the given path. |
Project |
usePlugin(java.lang.Class<? extends Plugin> pluginClass)
Applies a Plugin to this project. |
Project |
usePlugin(java.lang.Class<? extends Plugin> pluginClass,
java.util.Map<java.lang.String,?> customValues)
Applies a Plugin to this project. |
Project |
usePlugin(java.lang.String pluginName)
Applies a Plugin to this project. |
Project |
usePlugin(java.lang.String pluginName,
java.util.Map<java.lang.String,?> customValues)
Applies a Plugin to this project. |
| Methods inherited from interface java.lang.Comparable |
|---|
compareTo |
| Field Detail |
|---|
static final java.lang.String DEFAULT_BUILD_FILE
static final java.lang.String EMBEDDED_SCRIPT_ID
static final java.lang.String DEFAULT_ARCHIVES_TASK_BASE_NAME
static final java.lang.String PATH_SEPARATOR
static final java.lang.String DEFAULT_BUILD_DIR_NAME
static final java.lang.String GRADLE_PROPERTIES
static final java.lang.String SYSTEM_PROP_PREFIX
static final java.lang.String TMP_DIR_NAME
static final java.lang.String CACHE_DIR_NAME
| Method Detail |
|---|
Project getRootProject()
Returns the root project for the hierarchy that this project belongs to. In the case of a single-project build, this method returns this project.
You can access this property in your build file using rootProject
java.io.File getRootDir()
Returns the root directory of this project. The root directory is the project directory of the root project.
You can access this property in your build file using rootDir
java.io.File getBuildDir()
Returns the build directory of this project. The build directory is the directory which all artifacts are
generated into. The default value for the build directory is projectDir/build
You can access this property in your build file using buildDir
java.lang.String getBuildDirName()
Returns the name of the build directory of this project. It is resolved relative to the project directory of this project to determine the build directory. The default value is "build".
You can access this property in your build file using buildDirName
void setBuildDirName(java.lang.String buildDirName)
Sets the build directory name of this project.
buildDirName - The build dir name. Should not be null.java.lang.String getGradleUserHome()
Returns the home directory for a Gradle user. Default's to USER_HOME/.gradle
You can access this property in your build file using gradleUserHome
java.lang.String getBuildFileName()
Returns the name of the build file Gradle tries to apply against this project object. The default is
"build.gradle". If an embedded script is provided the build file name is "embedded_script".
You can access this property in your build file using buildFileName
getBuildFileClassName()java.lang.String getBuildFileClassName()
Returns the name of the classname the build file compiles to. They might be the same but not necessarily. If the build file name contains characters which are illegal for a class name, they are replaced in the build file name with underscores. In case of an embedded build script, the build file name and the build file class name are equal to "embedded_script". In case there is no build file provided for a project, Gradle injects an empty embedded script which obeys to the same naming convention as described above.
getBuildFileName()Project getParent()
Returns the parent project of this project, if any.
You can access this property in your build file using parent
java.lang.String getName()
Returns the name of this project. The project's name is not necessarily unique within a project hierarchy. You
should use the getPath() method for a unique identifier for the project.
You can access this property in your build file using name
java.util.Map<java.lang.String,Project> getChildProjects()
Returns the direct children of this project.
You can access this property in your build file using childProjects
java.util.Set<Project> getDependsOnProjects()
Returns the set of projects which this project depends on.
You can access this property in your build file using dependsOnProjects
void setProperty(java.lang.String name,
java.lang.Object value)
Sets a property of this project. This method searches for a property with the given name in the following locations, and sets the property on the first location where it finds the property.
rootDir project property.Convention object. For example, the srcRootName java plugin
property.If the property is not found in any of these locations, it is added to the project's additional properties.
name - The name of the propertyvalue - The value of the propertyProject getProject()
Returns this project. This method is useful in build files to explicitly access project properties and
methods. For example, using project.name can express intent better than using name
You can access this property in your build file using project
java.util.Set<Project> getAllprojects()
Returns the set containing this project and its subprojects.
You can access this property in your build file using allprojects
java.util.Set<Project> getSubprojects()
Returns the set containing the subprojects of this project.
You can access this property in your build file using subprojects
Project usePlugin(java.lang.String pluginName)
Applies a Plugin to this project.
pluginName - The name of the plugin.
Project usePlugin(java.lang.String pluginName,
java.util.Map<java.lang.String,?> customValues)
Applies a Plugin to this project.
pluginName - The name of the plugin.customValues - Configuration parameters to use to apply the plugin to this project.
Project usePlugin(java.lang.Class<? extends Plugin> pluginClass,
java.util.Map<java.lang.String,?> customValues)
Applies a Plugin to this project.
pluginClass - The class of the plugin. This class must implement the Plugin interface.customValues - Configuration parameters to use to apply the plugin to this project.
Project usePlugin(java.lang.Class<? extends Plugin> pluginClass)
Applies a Plugin to this project.
pluginClass - The class of the plugin. This class must implement the Plugin interface.
Task findTask(java.lang.String path)
Locates a Task by path. Relative paths are interpreted relative to this project. Returns null if no
such task exists.
path - the path of the task to be returned
Task task(java.lang.String path)
throws UnknownTaskException
Returns the Task from the project which has the given path. Relative paths are interpreted relative to
this project. If no such task exists, an exception is thrown.
You can also call this method in your build file using the task name. See here for more details.
path - the path of the task to be returned
UnknownTaskException - If no task with the given path exists.
Task task(java.lang.String path,
groovy.lang.Closure configurationClosure)
throws UnknownTaskException
Returns the Task from this project which has the given path. Relative paths are interpreted relative
to this project. Before the task is returned, the given closure is passed to the task's Task.configure(groovy.lang.Closure) method. If no such task exists, an exception is thrown.
You can call this method in your build file using the task name followed by a code block.
path - the path of the task to be returnedconfigurationClosure - the closure to use to configure the task.
UnknownTaskException - If no task with the given path exists.
Task createTask(java.lang.String name)
throws InvalidUserDataException
Creates a Task with the given name and adds it to this project. Calling this method is equivalent to
calling createTask(java.util.Map, String) with an empty options map.
After the task is added to the project, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details
If a task with the given name already exists in this project, an exception is thrown.
name - The name of the task to be created
InvalidUserDataException - If a task with the given name already exists in this project.
Task createTask(java.lang.String name,
TaskAction action)
throws InvalidUserDataException
Creates a Task with the given name and adds it to this project. Before the task is returned, the given
action closure is passed to the task's Task.doFirst(TaskAction) method. Calling this method is equivalent
to calling createTask(java.util.Map, String, TaskAction) with an empty options map.
After the task is added to the project, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details
If a task with the given name already exists in this project, an exception is thrown.
name - The name of the task to be createdaction - The closure to be passed to the Task.doFirst(TaskAction) method of the created task.
InvalidUserDataException - If a task with the given name already exsists in this project.
Task createTask(java.util.Map<java.lang.String,?> args,
java.lang.String name)
throws InvalidUserDataException
Creates a Task with the given name and adds it to this project. A map of creation options can be
passed to this method to control how the task is created. The following options are available:
| Option | Description | Default Value |
|---|---|---|
"type" | The class of the task to create. | org.gradle.api.internal.DefaultTask |
"overwrite" | Replace an existing task? | false |
"dependsOn" | A task name or set of task names which this task depends on | [] |
After the task is added to the project, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details
If a task with the given name already exists in this project and the override option is not set
to true, an exception is thrown.
args - The task creation options.name - The name of the task to be created
InvalidUserDataException - If a task with the given name already exsists in this project.
Task createTask(java.util.Map<java.lang.String,?> args,
java.lang.String name,
TaskAction action)
throws InvalidUserDataException
Creates a Task with the given name and adds it to this project. Before the task is returned, the given
action closure is passed to the task's Task.doFirst(TaskAction) method. A map of creation options can be
passed to this method to control how the task is created. See createTask(java.util.Map, String) for the
available options.
After the task is added to the project, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details
If a task with the given name already exists in this project and the override option is not set
to true, an exception is thrown.
args - The task creation options.name - The name of the task to be createdaction - The closure to be passed to the Task.doFirst(TaskAction) method of the created task.
InvalidUserDataException - If a task with the given name already exsists in this project.
Task createTask(java.lang.String name,
groovy.lang.Closure action)
Creates a Task with the given name and adds it to this project. Before the task is returned, the given
action closure is passed to the task's Task.doFirst(Closure) method. Calling this method is equivalent to
calling createTask(java.util.Map, String, Closure) with an empty options map.
After the task is added to the project, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details
If a task with the given name already exists in this project, an exception is thrown.
name - The name of the task to be createdaction - The closure to be passed to the Task.doFirst(Closure) method of the created task.
InvalidUserDataException - If a task with the given name already exsists in this project.
Task createTask(java.util.Map<java.lang.String,?> args,
java.lang.String name,
groovy.lang.Closure action)
Creates a Task with the given name and adds it to this project. Before the task is returned, the given
action closure is passed to the task's Task.doFirst(Closure) method. A map of creation options can be
passed to this method to control how the task is created. See createTask(java.util.Map, String) for the
available options.
After the task is added to the project, it is made available as a property of the project, so that you can reference the task by name in your build file. See here for more details
If a task with the given name already exists in this project and the override option is not set
to true, an exception is thrown.
args - The task creation options.name - The name of the task to be createdaction - The closure to be passed to the Task.doFirst(Closure) method of the created task.
InvalidUserDataException - If a task with the given name already exsists in this project.java.lang.String getArchivesTaskBaseName()
Returns the default prefix for naming archive tasks created via Bundle
tasks.
setArchivesBaseName(String)void setArchivesTaskBaseName(java.lang.String archivesTaskBaseName)
Sets the default prefix used for naming archive tasks. This is used if you create archive task via Bundle tasks. For example libs.jar() creates an archive task with the
name of the default prefix plus "_jar". The default for the default prefix is archive.
archivesTaskBaseName - The value (never null) for the archivesTaskBaseNamejava.lang.String getArchivesBaseName()
Returns the default prefix for naming archives generated by bundle archive tasks.
setArchivesBaseName(String)void setArchivesBaseName(java.lang.String archivesBaseName)
The default prefix for naming the archives generated by archive task. This is used if you create archive task
via bundles. For example libs.jar() generates an archive with the name of the default prefix plus
".jar". The default for the default prefix is the name of the project.
archivesBaseName - The value (never null) for the archivesBaseNamejava.lang.String getPath()
Returns the path of this project. The path is the fully qualified name of the project.
java.util.List<java.lang.String> getDefaultTasks()
Returns the names of the default tasks of this project. These are used when no tasks names are provided when starting the build.
void setDefaultTasks(java.util.List<java.lang.String> defaultTasks)
Sets the names of the default tasks of this project. These are used when no tasks names are provided when starting the build.
defaultTasks - The default task names.void defaultTasks(java.lang.String... defaultTasks)
Sets the names of the default tasks of this project. These are used when no tasks names are provided when starting the build.
defaultTasks - The default task names.
void dependsOn(java.lang.String path)
throws UnknownProjectException
Declares that this project has an execution dependency on the project with the given path.
path - The path of the project which this project depends on.
UnknownProjectException - If no project with the given path exists.
void dependsOn(java.lang.String path,
boolean evaluateDependsOnProject)
throws UnknownProjectException
Declares that this project has an execution dependency on the project with the given path.
path - The path of the project which this project depends on.evaluateDependsOnProject - If true, adds an evaluation dependency.
UnknownProjectException - If no project with the given path exists.
Project evaluationDependsOn(java.lang.String path)
throws UnknownProjectException
Declares that this project has an evaulation dependency on the project with the given path.
path - The path of the project which this project depends on.
UnknownProjectException - If no project with the given path exists.Project childrenDependOnMe()
Declares that all child projects of this project have an execution dependency on this project.
Project dependsOnChildren()
Declares that this project have an execution dependency on each of its child projects.
Project dependsOnChildren(boolean evaluateDependsOnProject)
Declares that this project have an execution dependency on each of its child projects.
evaluateDependsOnProject - If true, adds an evaluation dependency.
Project findProject(java.lang.String path)
Locates a project by path. If the path is relative, it is interpreted relative to this project.
path - The path.
Project project(java.lang.String path)
throws UnknownProjectException
Locates a project by path. If the path is relative, it is interpreted relative to this project.
path - The path.
UnknownProjectException - If no project with the given path exists.
Project project(java.lang.String path,
groovy.lang.Closure configureClosure)
Locates a project by path and configures it using the given closure. If the path is relative, it is interpreted relative to this project.
path - The path.configureClosure - The closure to use to configure the project.
UnknownProjectException - If no project with the given path exists.java.util.Map<Project,java.util.Set<Task>> getAllTasks(boolean recursive)
Returns a map of the tasks contained in this project, and optionally its subprojects.
recursive - If true, returns the tasks of this project and its subprojects. If false, returns the tasks of
just this project.
java.util.Set<Task> getTasksByName(java.lang.String name,
boolean recursive)
name - The name of the task to locate.recursive - If true, returns the tasks of this project and its subprojects. If false, returns the tasks of
just this project.
java.io.File getProjectDir()
The directory containing the project build file.
You can access this property in your build file using projectDir
java.io.File file(java.lang.Object path)
Resolves a file path relative to the project directory of this project.
path - An object which toString method value is interpreted as a relative path to the project directory.
java.io.File file(java.lang.Object path,
PathValidation validation)
throws InvalidUserDataException
Resolves a file path relative to the project directory of this project and validates it using the given
scheme. See PathValidation for the list of possible validations.
path - An object which toString method value is interpreted as a relative path to the project directory.
InvalidUserDataException - When the file does not meet the given validation constraint.java.io.File relativePath(java.lang.Object path)
Returns a file object with a relative path to the project directory. If the passed path is already a relative path, a file object with the same path is returned. If the passed path is an absolute path, a file object either the relative path to the project dir is returned, or null, if the absolute path has not the project dir as one of its parent dirs.
path - An object which toString method value is interpreted as path.
java.lang.String absolutePath(java.lang.String path)
Converts a name to an absolute project path, resolving names relative to this project.
path - The path to convert.
groovy.util.AntBuilder getAnt()
Returns the AntBuilder for this project. You can use this in your build file to execute ant
tasks.
You can access this property in your build file using ant
AntBuilder for this project. Never returns null.groovy.util.AntBuilder createAntBuilder()
Creates and additional AntBuilder for this project. You can use this in your build file to
execute ant tasks.
AntBuilder for this project. Never returns null.getAnt()groovy.util.AntBuilder ant(groovy.lang.Closure configureClosure)
Executes the given closure against the AntBuilder for this project. You can use this in your
build file to execute ant tasks.
You can call this method in your build file using ant followed by a code block.
configureClosure - The closure to execute against the AntBuilder. The closure receives no
paramters.
AntBuilder. Never returns null.DependencyManager getDependencies()
Return the DependencyManager for this project.
You can access this property in your build file using dependencies
DependencyManager. Never returns null.DependencyManager dependencies(groovy.lang.Closure configureClosure)
Executes the given closure against the DependencyManager for this project.
You can call this method in your build file using dependencies followed by a code block.
configureClosure - The closure to execute against the DependencyManager. The closure receives no
parameters.
DependencyManager. Never returns null.Convention getConvention()
Return the Convention for this project.
You can access this property in your build file using convention. You can also can also access
the properties and methods of the convention object as if they were properties and methods of this project. See
here for more details
Convention. Never returns null.int depthCompare(Project otherProject)
Compares the nesting level of this project with another project of the multi-project hierarchy.
otherProject - The project to compare the nesting level with.
getDepth()int getDepth()
Returns the nesting level of a project in a multi-project hierarchy. For single project builds this is always 0. In a multi-project hierarchy 0 is returned for the root project.
java.util.Map<java.lang.String,Task> getTasks()
Returns the tasks of this project.
Task object. Returns an empty map when this project has no tasks.java.util.Set<java.lang.Class<? extends Plugin>> getAppliedPlugins()
Returns the set of plugin types which have been applied to this project.
void subprojects(ProjectAction action)
Executes the given ProjectAction against the subprojects of this project.
action - The action to execute.void subprojects(groovy.lang.Closure configureClosure)
Executes the given closure against each of the subprojects of this project.
You can call this method in your build file using subprojects followed by a code block.
configureClosure - The closure to execute. The closure receives no parameters.void allprojects(ProjectAction action)
Executes the given ProjectAction against this project and its subprojects.
action - The action to execute.void allprojects(groovy.lang.Closure configureClosure)
Executes the given closure against this project and its subprojects.
You can call this method in your build file using allprojects followed by a code block.
configureClosure - The closure to execute. The closure receives no parameters.
void applyActions(java.util.Set<Project> projects,
ProjectAction action)
projects - action - AfterEvaluateListener addAfterEvaluateListener(AfterEvaluateListener afterEvaluateListener)
Adds an AfterEvaluateListener to this project. Such a listener gets notified when the build file
belonging to this project has been executed. A parent project may for example add such a listener to its child
project. Such a listener can futher configure those child projects based on the state of the child projects after
there build files have been run.
afterEvaluateListener - The listener (never null) to be added.
AfterEvaluateListenervoid addAfterEvaluateListener(groovy.lang.Closure afterEvaluateListener)
Adds the given closure as an AfterEvaluateListener. See addAfterEvaluateListener(AfterEvaluateListener)
for more details.
afterEvaluateListener - The listener to be added.java.util.List<AfterEvaluateListener> getAfterEvaluateListeners()
Returns all AfterEvaluateListeners of this project.
addAfterEvaluateListener(AfterEvaluateListener),
AfterEvaluateListenerboolean hasProperty(java.lang.String propertyName)
Determines if this project has the given property. See here for details of the properties which are available for a project.
propertyName - The name of the property to locate.
java.util.Map<java.lang.String,?> getProperties()
Returns the properties of this project. See here for details of the properties which are available for a project.
java.lang.Object property(java.lang.String propertyName)
throws groovy.lang.MissingPropertyException
MissingPropertyException
propertyName - The name of the property.
groovy.lang.MissingPropertyException - When the given property is unknown.org.slf4j.Logger getLogger()
Returns the logger for this project. You can use this in your build file to write log messages.
You can use this property in your build file using logger.
Build getBuild()
Returns the Build which this project belongs to.
You can use this property in your build file using build.
void disableStandardOutputCapture()
captureStandardOutput(org.gradle.api.logging.LogLevel)void captureStandardOutput(LogLevel level)
StandardOutputLogging.
level - The level standard out should be logged to.disableStandardOutputCapture(),
Task.captureStandardOutput(org.gradle.api.logging.LogLevel),
Task.disableStandardOutputCapture()
java.lang.Object configure(java.lang.Object object,
groovy.lang.Closure configureClosure)
MyType myType = new MyType() myType.doThis() myType.doThat()you can do:
MyType myType = configure(new MyType()) {
doThis()
doThat()
}
object - The object to configureconfigureClosure - The closure with configure statements
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||