|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD |
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
can programmatically access all 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 org.gradle.api.initialization.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). You can locate existing tasks using one of the lookup methods on TaskContainer, such as TaskContainer#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 org.gradle.api.artifacts.dsl.ConfigurationHandler returned by #getConfigurations() ()} method to manage the configurations. The org.gradle.api.artifacts.dsl.DependencyHandler returned by #getDependencies() method to manage the dependencies. The org.gradle.api.artifacts.dsl.ArtifactHandler returned by #getArtifacts() ()} method to manage the artifacts. The org.gradle.api.artifacts.dsl.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 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.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.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_GROUP
|
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 | |
---|---|
java.lang.String
|
absolutePath(java.lang.String path)
Converts a name to an absolute project path, resolving names relative to this project. |
void
|
afterEvaluate(Action action)
Adds an action to execute immediately after this project is evaluated. |
void
|
afterEvaluate(Closure closure)
Adds a closure to be called immediately after this project has been evaluated. |
void
|
allprojects(Action action)
Executes the given { |
void
|
allprojects(Closure configureClosure)
Executes the given closure against this project and its sub-projects. |
AntBuilder
|
ant(Closure configureClosure)
Executes the given closure against the |
void
|
applyActions(Set projects, Action action)
|
void
|
artifacts(Closure configureClosure)
Configures the published artifacts for this project. |
void
|
beforeEvaluate(Action action)
Adds an action to execute immediately before this project is evaluated. |
void
|
beforeEvaluate(Closure closure)
Adds a closure to be called immediately before this project is evaluated. |
void
|
buildscript(Closure configureClosure)
Configures the build script classpath for this project. |
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. |
void
|
configurations(Closure configureClosure)
Configures the dependency configurations for this project. |
java.lang.Object
|
configure(java.lang.Object object, Closure configureClosure)
Configures an object via a closure, with the closure's delegate set to the supplied object. |
java.lang.Iterable
|
configure(java.lang.Iterable objects, Closure configureClosure)
Configures a collection of objects via a closure. |
WorkResult
|
copy(Closure closure)
Copy the specified files. |
AntBuilder
|
createAntBuilder()
Creates an additional |
RepositoryHandler
|
createRepositoryHandler()
Creates a new repository handler. |
Task
|
createTask(java.lang.String name)
Creates a { |
Task
|
createTask(java.lang.String name, TaskAction action)
Creates a { |
Task
|
createTask(Map args, java.lang.String name)
Creates a { |
Task
|
createTask(Map args, java.lang.String name, TaskAction action)
Creates a { |
Task
|
createTask(java.lang.String name, Closure action)
Creates a { |
Task
|
createTask(Map args, java.lang.String name, Closure action)
Creates a { |
void
|
defaultTasks(java.lang.String defaultTasks)
Sets the names of the default tasks of this project. |
void
|
dependencies(Closure configureClosure)
Configures the dependencies 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. |
File
|
file(java.lang.Object path)
Resolves a file path relative to the project directory of this project. |
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. |
ConfigurableFileTree
|
fileTree(java.lang.Object baseDir)
Creates a new { |
ConfigurableFileTree
|
fileTree(Map args)
Creates a new { |
ConfigurableFileTree
|
fileTree(Closure closure)
Creates a new { |
ConfigurableFileCollection
|
files(java.lang.Object paths)
Returns a { |
ConfigurableFileCollection
|
files(java.lang.Object paths, Closure configureClosure)
Creates a new { |
Project
|
findProject(java.lang.String path)
Locates a project by path. |
Map
|
getAllTasks(boolean recursive)
Returns a map of the tasks contained in this project, and optionally its subprojects. |
Set
|
getAllprojects()
Returns the set containing this project and its subprojects. |
AntBuilder
|
getAnt()
Returns the |
ArtifactHandler
|
getArtifacts()
Returns a handler for assigning artifacts produced by the project to configurations. |
File
|
getBuildDir()
Returns the build directory of this project. |
java.lang.String
|
getBuildDirName()
Returns the name of the build directory of this project. |
File
|
getBuildFile()
Returns the build file Gradle will evaulate against this project object. |
ScriptHandler
|
getBuildscript()
Returns the build script handler for this project. |
Map
|
getChildProjects()
Returns the direct children of this project. |
ConfigurationHandler
|
getConfigurations()
Returns the configurations of this project. |
Convention
|
getConvention()
Return the { |
List
|
getDefaultTasks()
Returns the names of the default tasks of this project. |
DependencyHandler
|
getDependencies()
Returns the dependencies of this project. |
Set
|
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. |
Gradle
|
getGradle()
Returns the { |
java.lang.Object
|
getGroup()
Returns the group of this project. |
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. |
ProjectPluginsContainer
|
getPlugins()
Returns the plugins container for this project. |
Project
|
getProject()
Returns this project. |
File
|
getProjectDir()
The directory containing the project build file. |
Map
|
getProperties()
Returns the properties of this project. |
RepositoryHandler
|
getRepositories()
Returns a handler to create repositories which are used for retrieving dependencies and uploading artifacts produced by the project. |
File
|
getRootDir()
Returns the root directory of this project. |
Project
|
getRootProject()
Returns the root project for the hierarchy that this project belongs to. |
java.lang.Object
|
getStatus()
Returns the status of this project. |
Set
|
getSubprojects()
Returns the set containing the subprojects of this project. |
TaskContainer
|
getTasks()
Returns the tasks of this project. |
Set
|
getTasksByName(java.lang.String name, boolean recursive)
Returns the set of tasks with the given name contained in this project, and optionally its subprojects. |
java.lang.Object
|
getVersion()
Returns the version of this project. |
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, 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. |
File
|
relativePath(java.lang.Object path)
Returns a file object with a relative path to the project directory. |
void
|
repositories(Closure configureClosure)
Configures the repositories for this project. |
void
|
setBuildDirName(java.lang.String buildDirName)
Sets the build directory name of this project. |
void
|
setDefaultTasks(List 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(Action action)
Executes the given { |
void
|
subprojects(Closure configureClosure)
Executes the given closure against each of the sub-projects of this project. |
Task
|
task(java.lang.String name)
Creates a { |
Task
|
task(Map args, java.lang.String name)
Creates a { |
Task
|
task(Map args, java.lang.String name, Closure configureClosure)
Creates a { |
Task
|
task(java.lang.String name, Closure configureClosure)
Creates a { |
Project
|
usePlugin(java.lang.String pluginName)
Applies a { |
Project
|
usePlugin(java.lang.Class pluginClass)
Applies a { |
Methods inherited from interface java.lang.Comparable | |
---|---|
compareTo |
Methods inherited from class java.lang.Object | |
---|---|
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll |
Field Detail |
---|
static final java.lang.String DEFAULT_BUILD_DIR_NAME
static final java.lang.String DEFAULT_BUILD_FILE
static final java.lang.String DEFAULT_GROUP
static final java.lang.String DEFAULT_STATUS
static final java.lang.String DEFAULT_VERSION
static final java.lang.String GRADLE_PROPERTIES
static final java.lang.String PATH_SEPARATOR
static final java.lang.String SYSTEM_PROP_PREFIX
static final java.lang.String TMP_DIR_NAME
Method Detail |
---|
public java.lang.String absolutePath(java.lang.String path)
Converts a name to an absolute project path, resolving names relative to this project.
public void afterEvaluate(Action action)
public void afterEvaluate(Closure closure)
Adds a closure to be called immediately after this project has been evaluated. The project is passed to the closure as a parameter. 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 their build files have been run.
public void allprojects(Action action)
Executes the given Action against this project and its subprojects.
public void allprojects(Closure configureClosure)
Executes the given closure against this project and its sub-projects. The target project is passed to the closure as the closure's delegate.
You can call this method in your build file using allprojects
followed by a code block.
public AntBuilder ant(Closure configureClosure)
Executes the given closure against the AntBuilder
for this project. You can use this in your
build file to execute ant tasks. The AntBuild
is passed to the closure as the closure's
delegate.
You can call this method in your build file using ant
followed by a code block.
AntBuilder
.
AntBuilder
. Never returns null.
public void applyActions(Set projects, Action action)
public void artifacts(Closure configureClosure)
public void beforeEvaluate(Action action)
public void beforeEvaluate(Closure closure)
Adds a closure to be called immediately before this project is evaluated. The project is passed to the closure as a parameter.
public void buildscript(Closure configureClosure)
public void captureStandardOutput(LogLevel level)
public Project childrenDependOnMe()
Declares that all child projects of this project have an execution dependency on this project.
public void configurations(Closure configureClosure)
public java.lang.Object configure(java.lang.Object object, Closure configureClosure)
MyType myType = new MyType() myType.doThis() myType.doThat()you can do:
MyType myType = configure(new MyType()) { doThis() doThat() }
public java.lang.Iterable configure(java.lang.Iterable objects, Closure configureClosure)
public WorkResult copy(Closure closure)
copy { from configurations.runtime into 'build/deploy/lib' }Note that CopySpecs can be nested:
copy { into('build/webroot') exclude('**/.svn/**') from('src/main/webapp') { include '**/*.jsp' filter(ReplaceTokens, tokens:[copyright:'2009', version:'2.3.1']) } from('src/main/js') { include '**/*.js' } }
public AntBuilder createAntBuilder()
Creates an additional AntBuilder
for this project. You can use this in your build file to execute
ant tasks.
AntBuilder
for this project. Never returns null.
public RepositoryHandler createRepositoryHandler()
@Deprecated public Task createTask(java.lang.String name)
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.
@Deprecated public Task createTask(java.lang.String name, TaskAction action)
Creates a Task with the given name and adds it to this project. Before the task is returned, the given action is passed to the task's Task#doFirst(Action) 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.
@Deprecated public Task createTask(Map args, java.lang.String name)
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 |
---|---|---|
{ | The class of the task to create. | org.gradle.api.DefaultTask |
{ | Replace an existing task? | false |
{ | 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.
@Deprecated public Task createTask(Map args, java.lang.String name, TaskAction action)
Creates a Task with the given name and adds it to this project. Before the task is returned, the given action is passed to the task's Task#doFirst(Action) 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.
@Deprecated public Task createTask(java.lang.String name, 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.
@Deprecated public Task createTask(Map args, java.lang.String name, 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.
public 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.
public void dependencies(Closure configureClosure)
public void dependsOn(java.lang.String path)
Declares that this project has an execution dependency on the project with the given path.
public void dependsOn(java.lang.String path, boolean evaluateDependsOnProject)
Declares that this project has an execution dependency on the project with the given path.
public Project dependsOnChildren()
Declares that this project have an execution dependency on each of its child projects.
public Project dependsOnChildren(boolean evaluateDependsOnProject)
Declares that this project have an execution dependency on each of its child projects.
public int depthCompare(Project otherProject)
Compares the nesting level of this project with another project of the multi-project hierarchy.
public void disableStandardOutputCapture()
public Project evaluationDependsOn(java.lang.String path)
Declares that this project has an evaulation dependency on the project with the given path.
public File file(java.lang.Object path)
Resolves a file path relative to the project directory of this project.
path.toString will be used to get a string path. If this string can be interpreted as a relative path, the project directory will be used as a base directory.
public 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. See PathValidation for the list of possible validations.
public ConfigurableFileTree fileTree(java.lang.Object baseDir)
Creates a new ConfigurableFileTree using the given base directory. The given baseDir path is evaluated as for #file(Object).
The returned file tree is lazy, so that it scans for files only when the contents of the file tree are queried. The file tree is also live, so that it scans for files each time the contents of the file tree are queried.
public ConfigurableFileTree fileTree(Map args)
Creates a new ConfigurableFileTree using the provided map of arguments. The map will be applied as properties on the new file tree. Example:
fileTree(dir:'src', excludes:['**/ignore/**','**/.svn/**'])
The returned file tree is lazy, so that it scans for files only when the contents of the file tree are queried. The file tree is also live, so that it scans for files each time the contents of the file tree are queried.
public ConfigurableFileTree fileTree(Closure closure)
Creates a new ConfigurableFileTree using the provided closure. The closure will be used to configure the new file tree. The file tree is passed to the closure as its delegate. Example:
fileTree { from 'src' exclude '**/.svn/**' }.copy { into 'dest'}
The returned file tree is lazy, so that it scans for files only when the contents of the file tree are queried. The file tree is also live, so that it scans for files each time the contents of the file tree are queried.
public ConfigurableFileCollection files(java.lang.Object paths)
Returns a ConfigurableFileCollection containing the given files. You can pass any of the following types to this method:
The returned file collection is lazy, so that the paths are evaluated only when the contents of the file collection are queried. The file collection is also live, so that it evaluates the above each time the contents of the collection is queried.
The returned file collection maintains the iteration order of the supplied paths.
public ConfigurableFileCollection files(java.lang.Object paths, Closure configureClosure)
Creates a new ConfigurableFileCollection using the given paths. The paths are evaluated as for #files(Object...). The file collection is configured using the given closure. The file collection is passed to the closure as its delegate. Example:
files "$buildDir/classes" { builtBy 'compile' }
The returned file collection is lazy, so that the paths are evaluated only when the contents of the file collection are queried. The file collection is also live, so that it evaluates the above each time the contents of the collection is queried.
public Project findProject(java.lang.String path)
Locates a project by path. If the path is relative, it is interpreted relative to this project.
public Map getAllTasks(boolean recursive)
Returns a map of the tasks contained in this project, and optionally its subprojects.
public Set getAllprojects()
Returns the set containing this project and its subprojects.
You can access this property in your build file using allprojects
public 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.
public ArtifactHandler getArtifacts()
public 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
public 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 {
You can access this property in your build file using buildDirName
public File getBuildFile()
Returns the build file Gradle will evaulate against this project object. The default is {
. If an embedded script is provided the build file will be null.
You can access this property in your build file using buildFile
public ScriptHandler getBuildscript()
public Map getChildProjects()
Returns the direct children of this project.
You can access this property in your build file using childProjects
public ConfigurationHandler getConfigurations()
public 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.
public List getDefaultTasks()
Returns the names of the default tasks of this project. These are used when no tasks names are provided when starting the build.
public DependencyHandler getDependencies()
public Set getDependsOnProjects()
Returns the set of projects which this project depends on.
You can access this property in your build file using dependsOnProjects
public 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.
public Gradle getGradle()
Returns the org.gradle.api.invocation.Gradle which this project belongs to.
You can use this property in your build file using gradle
.
public java.lang.Object getGroup()
Returns the group of this project. Gradle always uses the toString() value of a group. The group defaults to {
You can access this property in your build file using group
public 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
.
public 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
public Project getParent()
Returns the parent project of this project, if any.
You can access this property in your build file using parent
public java.lang.String getPath()
Returns the path of this project. The path is the fully qualified name of the project.
public ProjectPluginsContainer getPlugins()
public Project 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
public File getProjectDir()
The directory containing the project build file.
You can access this property in your build file using projectDir
public Map getProperties()
Returns the properties of this project. See here for details of the properties which are available for a project.
public RepositoryHandler getRepositories()
public 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
public 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
public java.lang.Object getStatus()
Returns the status of this project. Gradle always uses the toString() value of a version. The status defaults to {
You can access this property in your build file using status
public Set getSubprojects()
Returns the set containing the subprojects of this project.
You can access this property in your build file using subprojects
public TaskContainer getTasks()
Returns the tasks of this project.
public Set getTasksByName(java.lang.String name, boolean recursive)
public java.lang.Object getVersion()
Returns the version of this project. Gradle always uses the toString() value of a version. The version defaults to {
You can access this property in your build file using version
public boolean 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.
public Project project(java.lang.String path)
Locates a project by path. If the path is relative, it is interpreted relative to this project.
public Project project(java.lang.String path, 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. The target project is passed to the closure as the closure's delegate.
public java.lang.Object property(java.lang.String propertyName)
public 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.
public void repositories(Closure configureClosure)
public void setBuildDirName(java.lang.String buildDirName)
Sets the build directory name of this project.
public void setDefaultTasks(List defaultTasks)
Sets the names of the default tasks of this project. These are used when no tasks names are provided when starting the build.
public 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.srcRootName
java plugin
property.If the property is not found in any of these locations, it is added to the project's additional properties.
public void subprojects(Action action)
Executes the given Action against the subprojects of this project.
public void subprojects(Closure configureClosure)
Executes the given closure against each of the sub-projects of this project. The target project is passed to the closure as the closure's delegate.
You can call this method in your build file using subprojects
followed by a code block.
public Task task(java.lang.String name)
Creates a Task with the given name and adds it to this project. Calling this method is equivalent to calling #task(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.
public Task task(Map args, java.lang.String name)
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 |
---|---|---|
{ | The class of the task to create. | org.gradle.api.DefaultTask |
{ | Replace an existing task? | false |
{ | A task name or set of task names which this task depends on | [] |
{ | A closure or TaskAction to add to the task. | null |
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.
public Task task(Map args, java.lang.String name, Closure configureClosure)
Creates a Task with the given name and adds it to this project. Before the task is returned, the given closure is executed to configure the task. A map of creation options can be passed to this method to control how the task is created. See #task(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.
public Task task(java.lang.String name, Closure configureClosure)
Creates a Task with the given name and adds it to this project. Before the task is returned, the given closure is executed to configure the task.
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
public Project usePlugin(java.lang.String pluginName)
Applies a Plugin to this project.
public Project usePlugin(java.lang.Class pluginClass)
Applies a Plugin to this project.
Groovy Documentation