Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD

## org.gradle.api
[Java] Interface Project

    public interface Project
    extends java.lang.Comparable

This interface is the main API you use to interact with Gradle from your build file. From a `Project`, you have programmatic access to all of Gradle's features.

### Lifecycle

There is a one-to-one relationship between a `Project` and a `{`

value:
  #DEFAULT_BUILD_FILE} file. During build initialisation, Gradle assembles a `Project` object for each project which is to participate in the build, as follows:
  - Create a Settings instance for the build.
  - Evaluate the `{@value org.gradle.api.initialization.Settings#DEFAULT_SETTINGS_FILE}` script, if present, against the Settings object to configure it.
  - Use the configured Settings object to create the hierarchy of `Project` instances.
  - Finally, evaluate each `Project` by executing its `{@value #DEFAULT_BUILD_FILE}` 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.

  ### Tasks

  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 `add()` methods on TaskContainer, such as TaskContainer#add(String)#add(String). You can locate existing tasks using one of the lookup methods on TaskContainer, such as TaskContainer#getByName(String)#getByName(String).

  ### Dependencies

  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. Those dependencies are grouped in configurations, and can be retrieved and uploaded from repositories. You use the ConfigurationContainer returned by getConfigurations() ()} method to manage the configurations. The DependencyHandler returned by getDependencies() method to manage the dependencies. The ArtifactHandler returned by getArtifacts() ()} method to manage the artifacts. The RepositoryHandler returned by getRepositories() ()} method to manage the repositories.

  ### Multi-project Builds

  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.

  ### Using a Project in a Build File

  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:

       defaultTasks('some-task')  // Delegates 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 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, getRootProject() is accessible as the `rootProject` 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 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.
  - 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 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.

  #### 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 Plugin applied to the project. A Plugin can add properties and method to a project through the project's 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 Task.configure 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)`.
  - The parent project, recursively up to the root project.

Authors:
  Hans Dockter

Field Summary
`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` | `DEFAULT_STATUS`
`static java.lang.String` | `DEFAULT_VERSION`
`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

Methods inherited from interface java.lang.Comparable
java.lang.Comparable#compareTo(java.lang.Object)

Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Field Detail

### DEFAULT_BUILD_DIR_NAME

    public static final java.lang.String DEFAULT_BUILD_DIR_NAME

  The default build directory name.

### DEFAULT_BUILD_FILE

    public static final java.lang.String DEFAULT_BUILD_FILE

  The default project build file name.

### DEFAULT_STATUS

    public static final java.lang.String DEFAULT_STATUS

### DEFAULT_VERSION

    public static final java.lang.String DEFAULT_VERSION

### GRADLE_PROPERTIES

    public static final java.lang.String GRADLE_PROPERTIES

### PATH_SEPARATOR

    public static final java.lang.String PATH_SEPARATOR

  The hierarchy separator for project and task path names.

### SYSTEM_PROP_PREFIX

    public static final java.lang.String SYSTEM_PROP_PREFIX

### TMP_DIR_NAME

    public static final java.lang.String TMP_DIR_NAME

Groovy Documentation