|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD |
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.
There is a one-to-one relationship between a Project
and a {
file. During build initialisation, Gradle assembles a Project
object for each project which is to
participate in the build, as follows:
{@value org.gradle.api.initialization.Settings#DEFAULT_SETTINGS_FILE}
script, if
present, against the Settings object to configure it.Project
instances.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.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).
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.
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:
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.
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 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.compile
is accessible 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.compile
, then a
method is added with the following signature: void compile(Closure configureClosure)
.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(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), 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 |
---|
public static final java.lang.String DEFAULT_BUILD_DIR_NAME
public static final java.lang.String DEFAULT_BUILD_FILE
public static final java.lang.String DEFAULT_STATUS
public static final java.lang.String DEFAULT_VERSION
public static final java.lang.String GRADLE_PROPERTIES
public static final java.lang.String PATH_SEPARATOR
public static final java.lang.String SYSTEM_PROP_PREFIX
public static final java.lang.String TMP_DIR_NAME
Groovy Documentation