gates to Project.defaultTasks() 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.
Dynamic Properties
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 {@link #property(String)} method. The scopes are:
- The
Project
object itself. This scope includes any property getters and setters declared by the Project
implementation class. For example, {@link #getRootProject()} is accessible as therootProject
property. The properties of this scope are readable or writable depending on the presence of the corresponding getter or setter method. - The additional properties of the project. Each project maintains a map of additional properties, which can contain any arbitrary name -> value pair. The properties of this scope are readable and writable.
- The convention properties added to the project by each {@link Plugin} applied to the project. A {@link Plugin} can add properties and methods to a project through the project's {@link Convention} object. The propertiesof this scope may be readable or writable, depending on the convention objects.
- The tasks of the project. A task is accessible by using its name as a property name. The properties of this scope are read-only. For example, a task called
compile
is accessible as the compile
property. - The additional properties and convention properties of the project's parent project, recursively up to the root project. The properties of this scope are read-only.
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 {@link #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 {@link #setProperty(String,Object)} for more details.
Dynamic Methods
A project has 5 method 'scopes', which it searches for methods:
- The
Project
object itself. - The build file. The project searches for a matching method declared in the build file.
- The convention methods added to the project by each {@link Plugin} applied to the project. A {@link Plugin} can add properties and method to a project through the project's {@link Convention} object.
- The tasks of the project. A method is added for each task, using the name of the task as the method name and taking a single closure parameter. The method calls the {@link Task#configure(groovy.lang.Closure)} method for theassociated 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)
. - The parent project, recursively up to the root project.
@author Hans Dockter