public abstract class AbstractProject extends Object implements ProjectInternal, DynamicObjectAware
DEFAULT_BUILD_DIR_NAME, DEFAULT_BUILD_FILE, DEFAULT_STATUS, DEFAULT_VERSION, GRADLE_PROPERTIES, PATH_SEPARATOR, SYSTEM_PROP_PREFIX| Constructor and Description |
|---|
AbstractProject(String name,
ProjectInternal parent,
File projectDir,
ScriptSource buildScriptSource,
GradleInternal gradle,
ServiceRegistryFactory serviceRegistryFactory) |
| Modifier and Type | Method and Description |
|---|---|
String |
absoluteProjectPath(String path)
Converts a name to an absolute project path, resolving names relative to this project.
|
void |
addChildProject(ProjectInternal childProject) |
void |
afterCompile(ScriptPlugin configurer,
Script script) |
void |
afterEvaluate(Action<? super Project> 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<? super Project> action)
Configures this project and each of its sub-projects.
|
void |
allprojects(Closure configureClosure)
Configures this project and each of its sub-projects.
|
AntBuilder |
ant(Closure configureClosure)
Executes the given closure against the
AntBuilder for this project. |
void |
apply(Closure closure)
Configures this project using plugins or scripts.
|
void |
apply(Map<String,?> options)
Configures this project using plugins or scripts.
|
void |
artifacts(Closure configureClosure)
Configures the published artifacts for this project.
|
void |
beforeCompile(ScriptPlugin configurer) |
void |
beforeEvaluate(Action<? super Project> 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.
|
Project |
childrenDependOnMe()
Declares that all child projects of this project have an execution dependency on this project.
|
int |
compareTo(Project otherProject) |
void |
configurations(Closure configureClosure)
Configures the dependency configurations for this project.
|
Iterable<?> |
configure(Iterable<?> objects,
Closure configureClosure)
Configures a collection of objects via a closure.
|
<T> Iterable<T> |
configure(Iterable<T> objects,
Action<? super T> configureAction)
Configures a collection of objects via an action.
|
Object |
configure(Object object,
Closure configureClosure)
Configures an object via a closure, with the closure's delegate set to the supplied object.
|
<T> NamedDomainObjectContainer<T> |
container(Class<T> type)
Creates a container for managing named objects of the specified type.
|
<T> NamedDomainObjectContainer<T> |
container(Class<T> type,
Closure factoryClosure)
Creates a container for managing named objects of the specified type.
|
<T> NamedDomainObjectContainer<T> |
container(Class<T> type,
NamedDomainObjectFactory<T> factory)
Creates a container for managing named objects of the specified type.
|
WorkResult |
copy(Closure closure)
Copies the specified files.
|
CopySpec |
copySpec(Closure closure)
Creates a
CopySpec which can later be used to copy files or create an archive. |
AntBuilder |
createAntBuilder()
Creates an additional
AntBuilder for this project. |
Task |
createTask(Map<String,?> args,
String name,
Action<? super Task> action) |
Task |
createTask(Map args,
String name,
Closure action) |
void |
defaultTasks(String... defaultTasks)
Sets the names of the default tasks of this project.
|
boolean |
delete(Object... paths)
Deletes files and directories.
|
void |
dependencies(Closure configureClosure)
Configures the dependencies for this project.
|
void |
dependsOn(String path)
Declares that this project has an execution dependency on the project with the given path.
|
void |
dependsOn(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 has an execution dependency on each of its child projects.
|
Project |
dependsOnChildren(boolean evaluateDependsOnProject)
Declares that this project has 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.
|
org.gradle.api.tasks.Directory |
dir(String path)
Deprecated.
Use the
mkdir(Object) instead. |
AbstractProject |
evaluate() |
Project |
evaluationDependsOn(String path)
Declares that this project has an evaluation dependency on the project with the given path.
|
void |
evaluationDependsOnChildren()
Declares that this project has an evaluation dependency on each of its child projects.
|
ExecResult |
exec(Closure closure)
Executes an external command.
|
File |
file(Object path)
Resolves a file path relative to the project directory of this project.
|
File |
file(Object path,
PathValidation validation)
Resolves a file path relative to the project directory of this project and validates it using the given
scheme.
|
ConfigurableFileCollection |
files(Object... paths)
Returns a
ConfigurableFileCollection containing the given files. |
ConfigurableFileCollection |
files(Object paths,
Closure closure)
Creates a new
ConfigurableFileCollection using the given paths. |
ConfigurableFileTree |
fileTree(Closure closure)
Creates a new
ConfigurableFileTree using the provided closure. |
ConfigurableFileTree |
fileTree(Map<String,?> args)
Creates a new
ConfigurableFileTree using the provided map of arguments. |
ConfigurableFileTree |
fileTree(Object baseDir)
Creates a new
ConfigurableFileTree using the given base directory. |
ConfigurableFileTree |
fileTree(Object baseDir,
Closure closure)
Creates a new
ConfigurableFileTree using the given base directory. |
ProjectInternal |
findProject(String path)
Locates a project by path.
|
Set<Project> |
getAllprojects()
Returns the set containing this project and its subprojects.
|
Map<Project,Set<Task>> |
getAllTasks(boolean recursive)
Returns a map of the tasks contained in this project, and optionally its subprojects.
|
AntBuilder |
getAnt()
Returns the
AntBuilder for this project. |
Factory<AntBuilder> |
getAntBuilderFactory() |
ArtifactHandler |
getArtifacts()
Returns a handler for assigning artifacts produced by the project to configurations.
|
DynamicObject |
getAsDynamicObject()
Returns a
DynamicObject for this object. |
File |
getBuildDir()
Returns the build directory of this project.
|
File |
getBuildFile()
Returns the build file Gradle will evaluate against this project object.
|
ScriptHandler |
getBuildscript()
Returns the build script handler for this project.
|
ScriptSource |
getBuildScriptSource() |
Map<String,Project> |
getChildProjects()
Returns the direct children of this project.
|
ConfigurationContainerInternal |
getConfigurations()
Returns the configurations of this project.
|
Convention |
getConvention()
Returns the
Convention for this project. |
List<String> |
getDefaultTasks()
Returns the names of the default tasks of this project.
|
DependencyHandler |
getDependencies()
Returns the dependency handler of this project.
|
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.
|
String |
getDescription()
Returns the description of this project.
|
ExtensionContainer |
getExtensions()
Allows adding DSL extensions to the project.
|
FileResolver |
getFileResolver() |
GradleInternal |
getGradle()
Returns the
Gradle invocation which this project belongs to. |
Object |
getGroup()
Returns the group of this project.
|
TaskContainerInternal |
getImplicitTasks() |
DynamicObject |
getInheritedScope() |
Logger |
getLogger()
Returns the logger for this project.
|
LoggingManager |
getLogging()
Returns the
LoggingManager which can be used to control the logging level and
standard output/error capture for this project's build script. |
Module |
getModule() |
String |
getName()
Returns the name of this project.
|
ProjectInternal |
getParent()
Returns the parent project of this project, if any.
|
ProjectIdentifier |
getParentIdentifier() |
String |
getPath()
Returns the path of this project.
|
PluginContainer |
getPlugins()
Returns the plugins container for this project.
|
Project |
getProject()
This method is used when scripts access the project via project.x
|
File |
getProjectDir()
The directory containing the project build file.
|
ProjectEvaluationListener |
getProjectEvaluationBroadcaster() |
ProjectEvaluator |
getProjectEvaluator() |
IProjectRegistry<ProjectInternal> |
getProjectRegistry() |
Map<String,?> |
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.
|
ResourceHandler |
getResources()
Provides access to resource-specific utility methods, for example factory methods that create various resources.
|
File |
getRootDir()
Returns the root directory of this project.
|
ProjectInternal |
getRootProject()
Returns the root project for the hierarchy that this project belongs to.
|
ServiceRegistryFactory |
getServices() |
StandardOutputCapture |
getStandardOutputCapture() |
ProjectStateInternal |
getState()
Returns the evaluation state of this project.
|
Object |
getStatus()
Returns the status of this project.
|
Set<Project> |
getSubprojects()
Returns the set containing the subprojects of this project.
|
TaskContainerInternal |
getTasks()
Returns the tasks of this project.
|
Set<Task> |
getTasksByName(String name,
boolean recursive)
Returns the set of tasks with the given name contained in this project, and optionally its subprojects.
|
Object |
getVersion()
Returns the version of this project.
|
boolean |
hasProperty(String propertyName)
Determines if this project has the given property.
|
ExecResult |
javaexec(Closure closure)
Executes a Java main class.
|
File |
mkdir(Object path)
Creates a directory and returns a file pointing to it.
|
Object |
passThrough(Object object)
This is called by the task creation DSL.
|
ProjectInternal |
project(String path)
Locates a project by path.
|
Project |
project(String path,
Closure configureClosure)
Locates a project by path and configures it using the given closure.
|
Object |
property(String propertyName)
Returns the value of the given property.
|
String |
relativePath(Object path)
Returns the relative path from the project directory to the given path.
|
String |
relativeProjectPath(String path)
Converts a name to a project path relative to this project.
|
void |
repositories(Closure configureClosure)
Configures the repositories for this project.
|
void |
setAnt(AntBuilder ant) |
void |
setAntBuilderFactory(Factory<AntBuilder> antBuilderFactory) |
void |
setArtifactHandler(ArtifactHandler artifactHandler) |
void |
setBuildDir(Object path)
Sets the build directory of this project.
|
void |
setConfigurationContainer(ConfigurationContainerInternal configurationContainer) |
void |
setDefaultTasks(List<String> defaultTasks)
Sets the names of the default tasks of this project.
|
void |
setDependencyHandler(DependencyHandler dependencyHandler) |
void |
setDescription(String description)
Sets a description for this project.
|
void |
setFileResolver(FileResolver fileResolver) |
void |
setGroup(Object group)
Sets the group of this project.
|
void |
setProjectEvaluator(ProjectEvaluator projectEvaluator) |
void |
setProperty(String name,
Object value)
Sets a property of this project.
|
void |
setScript(Script buildScript) |
void |
setStatus(Object status)
Sets the status of this project.
|
void |
setTaskContainer(TaskContainerInternal taskContainer) |
void |
setVersion(Object version)
Sets the version of this project.
|
void |
subprojects(Action<? super Project> action)
Configures the sub-projects of this project
|
void |
subprojects(Closure configureClosure)
Configures the sub-projects of this project.
|
FileTree |
tarTree(Object tarPath)
Creates a new
FileTree which contains the contents of the given TAR file. |
Task |
task(Map options,
Object task) |
Task |
task(Map options,
Object task,
Closure configureClosure) |
Task |
task(Map options,
String task)
Creates a
Task with the given name and adds it to this project. |
Task |
task(Map options,
String task,
Closure configureClosure)
Creates a
Task with the given name and adds it to this project. |
Task |
task(Object task) |
Task |
task(Object task,
Closure configureClosure) |
Task |
task(String task)
Creates a
Task with the given name and adds it to this project. |
Task |
task(String task,
Closure configureClosure)
Creates a
Task with the given name and adds it to this project. |
String |
toString() |
URI |
uri(Object path)
Resolves a file path to a URI, relative to the project directory of this project.
|
FileTree |
zipTree(Object zipPath)
Creates a new
FileTree which contains the contents of the given ZIP file. |
public AbstractProject(String name, ProjectInternal parent, File projectDir, ScriptSource buildScriptSource, GradleInternal gradle, ServiceRegistryFactory serviceRegistryFactory)
public ProjectInternal getRootProject()
ProjectReturns the root project for the hierarchy that this project belongs to. In the case of a single-project build, this method returns this project.
getRootProject in interface ProjectInternalgetRootProject in interface Projectpublic GradleInternal getGradle()
ProjectReturns the Gradle invocation which this project belongs to.
getGradle in interface ProjectInternalgetGradle in interface Projectpublic PluginContainer getPlugins()
ProjectgetPlugins in interface Projectpublic ProjectEvaluator getProjectEvaluator()
public void setProjectEvaluator(ProjectEvaluator projectEvaluator)
public ScriptHandler getBuildscript()
ProjectgetBuildscript in interface Projectpublic void beforeCompile(ScriptPlugin configurer)
beforeCompile in interface ScriptAwarepublic void afterCompile(ScriptPlugin configurer, Script script)
afterCompile in interface ScriptAwarepublic File getBuildFile()
ProjectReturns the build file Gradle will evaluate against this project object. The default is "build.gradle". If an embedded script is provided the build file will be null.
getBuildFile in interface ProjectIdentifiergetBuildFile in interface Projectpublic void setScript(Script buildScript)
public ScriptSource getBuildScriptSource()
getBuildScriptSource in interface ProjectInternalpublic File getRootDir()
ProjectReturns the root directory of this project. The root directory is the project directory of the root project.
getRootDir in interface Projectpublic ProjectInternal getParent()
ProjectReturns the parent project of this project, if any.
getParent in interface ProjectInternalgetParent in interface Projectpublic ProjectIdentifier getParentIdentifier()
getParentIdentifier in interface ProjectIdentifierpublic DynamicObject getAsDynamicObject()
DynamicObjectAwareDynamicObject for this object.getAsDynamicObject in interface DynamicObjectAwarepublic DynamicObject getInheritedScope()
getInheritedScope in interface ProjectInternalpublic String getName()
ProjectReturns the name of this project. The project's name is not necessarily unique within a project hierarchy. You
should use the Project.getPath() method for a unique identifier for the project.
getName in interface ProjectIdentifiergetName in interface Projectpublic String getDescription()
ProjectgetDescription in interface Projectpublic void setDescription(String description)
ProjectsetDescription in interface Projectdescription - The description of the project. Might be null.public Object getGroup()
ProjectReturns the group of this project. Gradle always uses the toString() value of the group. The group
defaults to the path with dots a separators.
public void setGroup(Object group)
ProjectSets the group of this project.
public Object getVersion()
ProjectReturns the version of this project. Gradle always uses the toString() value of the version. The
version defaults to "unspecified".
getVersion in interface Projectpublic void setVersion(Object version)
ProjectSets the version of this project.
setVersion in interface Projectversion - The version of this project. Must not be null.public Object getStatus()
ProjectReturns the status of this project. Gradle always uses the toString() value of the status. The status
defaults to "release".
The status of the project is only relevant, if you upload libraries together with a module descriptor. The status specified here, will be part of this module descriptor.
public void setStatus(Object status)
Projectpublic Map<String,Project> getChildProjects()
ProjectReturns the direct children of this project.
getChildProjects in interface Projectpublic List<String> getDefaultTasks()
ProjectReturns the names of the default tasks of this project. These are used when no tasks names are provided when starting the build.
getDefaultTasks in interface Projectpublic void setDefaultTasks(List<String> defaultTasks)
ProjectSets the names of the default tasks of this project. These are used when no tasks names are provided when starting the build.
setDefaultTasks in interface ProjectdefaultTasks - The default task names.public Set<Project> getDependsOnProjects()
ProjectReturns the set of projects which this project depends on.
getDependsOnProjects in interface Projectpublic ProjectStateInternal getState()
Projectpublic FileResolver getFileResolver()
getFileResolver in interface FileOperationsgetFileResolver in interface ProjectInternalpublic void setFileResolver(FileResolver fileResolver)
public void setAnt(AntBuilder ant)
public ArtifactHandler getArtifacts()
ProjectArtifactHandlergetArtifacts in interface Projectpublic void setArtifactHandler(ArtifactHandler artifactHandler)
public RepositoryHandler getRepositories()
ProjectgetRepositories in interface Projectpublic ConfigurationContainerInternal getConfigurations()
ProjectConfigurationContainergetConfigurations in interface ProjectInternalgetConfigurations in interface Projectpublic void setConfigurationContainer(ConfigurationContainerInternal configurationContainer)
public Convention getConvention()
ProjectReturns 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
getConvention in interface ProjectConvention. Never returns null.public String getPath()
ProjectReturns the path of this project. The path is the fully qualified name of the project.
getPath in interface ProjectIdentifiergetPath in interface Projectpublic int getDepth()
ProjectReturns 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 IProjectRegistry<ProjectInternal> getProjectRegistry()
getProjectRegistry in interface ProjectInternalpublic int depthCompare(Project otherProject)
ProjectCompares the nesting level of this project with another project of the multi-project hierarchy.
depthCompare in interface ProjectotherProject - The project to compare the nesting level with.Project.getDepth()public int compareTo(Project otherProject)
compareTo in interface Comparable<Project>public String absoluteProjectPath(String path)
ProjectConverts a name to an absolute project path, resolving names relative to this project.
absoluteProjectPath in interface DomainObjectContextabsoluteProjectPath in interface Projectpath - The path to convert.public String relativeProjectPath(String path)
ProjectConverts a name to a project path relative to this project.
relativeProjectPath in interface Projectpath - The path to convert.public ProjectInternal project(String path)
ProjectLocates a project by path. If the path is relative, it is interpreted relative to this project.
project in interface ProjectInternalproject in interface Projectpath - The path.public ProjectInternal findProject(String path)
ProjectLocates a project by path. If the path is relative, it is interpreted relative to this project.
findProject in interface ProjectInternalfindProject in interface Projectpath - The path.public Set<Project> getAllprojects()
ProjectReturns the set containing this project and its subprojects.
getAllprojects in interface Projectpublic Set<Project> getSubprojects()
ProjectReturns the set containing the subprojects of this project.
getSubprojects in interface Projectpublic void subprojects(Action<? super Project> action)
ProjectConfigures the sub-projects of this project
This method executes the given Action against the sub-projects of this project.
subprojects in interface Projectaction - The action to execute.public void allprojects(Action<? super Project> action)
ProjectConfigures this project and each of its sub-projects.
This method executes the given Action against this project and each of its sub-projects.
allprojects in interface Projectaction - The action to execute.public <T> Iterable<T> configure(Iterable<T> objects, Action<? super T> configureAction)
Projectpublic AntBuilder getAnt()
ProjectReturns the AntBuilder for this project. You can use this in your build file to execute ant
tasks. See example below.
task printChecksum {
doLast {
ant {
//using ant checksum task to store the file checksum in the checksumOut ant property
checksum(property: 'checksumOut', file: 'someFile.txt')
//we can refer to the ant property created by checksum task:
println "The checksum is: " + checksumOut
}
//we can refer to the ant property later as well:
println "I just love to print checksums: " + ant.checksumOut
}
}
Consider following example of ant target:
<target name='printChecksum'>
<checksum property='checksumOut'>
<fileset dir='.'>
<include name='agile.txt'/>
</fileset>
</checksum>
<echo>The checksum is: ${checksumOut}</echo>
</target>
Here's how it would look like in gradle. Observe how the ant xml is represented in groovy by the ant builder
task printChecksum {
doLast {
ant {
checksum(property: 'checksumOut') {
fileset(dir: '.') {
include name: 'agile1.txt'
}
}
}
logger.lifecycle("The checksum is $ant.checksumOut")
}
}
public AntBuilder createAntBuilder()
ProjectCreates an additional AntBuilder for this project. You can use this in your build file to execute
ant tasks.
createAntBuilder in interface ProjectAntBuilder for this project. Never returns null.Project.getAnt()public Project getProject()
getProject in interface Projectpublic AbstractProject evaluate()
evaluate in interface ProjectInternalpublic TaskContainerInternal getTasks()
ProjectReturns the tasks of this project.
getTasks in interface ProjectInternalgetTasks in interface Projectpublic TaskContainerInternal getImplicitTasks()
getImplicitTasks in interface ProjectInternalpublic void defaultTasks(String... defaultTasks)
ProjectSets the names of the default tasks of this project. These are used when no tasks names are provided when starting the build.
defaultTasks in interface ProjectdefaultTasks - The default task names.public void addChildProject(ProjectInternal childProject)
addChildProject in interface ProjectInternalpublic File getProjectDir()
ProjectThe directory containing the project build file.
getProjectDir in interface ProjectIdentifiergetProjectDir in interface Projectpublic File getBuildDir()
ProjectReturns 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
getBuildDir in interface Projectpublic void setBuildDir(Object path)
ProjectSets the build directory of this project. The build directory is the directory which all artifacts are
generated into. The path parameter is evaluated as described for Project.file(Object). This mean you can use,
amongst other things, a relative or absolute path or File object to specify the build directory.
setBuildDir in interface Projectpath - The build directory. This is evaluated as for Project.file(Object)public void dependsOn(String path)
ProjectDeclares that this project has an execution dependency on the project with the given path.
public void dependsOn(String path, boolean evaluateDependsOnProject)
ProjectDeclares that this project has an execution dependency on the project with the given path.
public void evaluationDependsOnChildren()
ProjectDeclares that this project has an evaluation dependency on each of its child projects.
evaluationDependsOnChildren in interface Projectpublic Project evaluationDependsOn(String path)
ProjectDeclares that this project has an evaluation dependency on the project with the given path.
evaluationDependsOn in interface Projectpath - The path of the project which this project depends on.public Project childrenDependOnMe()
ProjectDeclares that all child projects of this project have an execution dependency on this project.
childrenDependOnMe in interface Projectpublic Project dependsOnChildren()
ProjectDeclares that this project has an execution dependency on each of its child projects.
dependsOnChildren in interface Projectpublic Project dependsOnChildren(boolean evaluateDependsOnProject)
ProjectDeclares that this project has an execution dependency on each of its child projects.
dependsOnChildren in interface ProjectevaluateDependsOnProject - If true, adds an evaluation dependency.public Map<Project,Set<Task>> getAllTasks(boolean recursive)
ProjectReturns a map of the tasks contained in this project, and optionally its subprojects.
getAllTasks in interface Projectrecursive - If true, returns the tasks of this project and its subprojects. If false, returns the tasks of
just this project.public Set<Task> getTasksByName(String name, boolean recursive)
ProjectReturns the set of tasks with the given name contained in this project, and optionally its subprojects.
getTasksByName in interface Projectname - 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.public File file(Object path)
ProjectResolves a file path relative to the project directory of this project. This method converts the supplied path based on its type:
CharSequence / String. Interpreted relative to the project directory, as for Project.file(Object). A string
that starts with file: is treated as a file URL.File. If the file is an absolute file, it is returned as is. Otherwise, the file's path is
interpreted relative to the project directory.URI or URL. The URL's path is interpreted as the file path. Currently, only
file: URLs are supported.
Closure. The closure's return value is resolved recursively.Callable. The callable's return value is resolved recursively.toString() value is treated the same way as a String, as for Project.file(Object).
This handling of custom Objects has been deprecated and will be removed in the next version of Gradle.file in interface FileOperationsfile in interface Projectpath - The object to resolve as a File.public File file(Object path, PathValidation validation)
ProjectResolves 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.
file in interface FileOperationsfile in interface Projectpath - An object which toString method value is interpreted as a relative path to the project directory.validation - The validation to perform on the file.public URI uri(Object path)
ProjectResolves a file path to a URI, relative to the project directory of this project. Evaluates the provided path
object as described for Project.file(Object), with the exception that any URI scheme is supported, not just
'file:' URIs.
uri in interface FileOperationsuri in interface Projectpath - The object to resolve as a URI.public ConfigurableFileCollection files(Object... paths)
ProjectReturns a ConfigurableFileCollection containing the given files. You can pass any of the following
types to this method:
CharSequence / String. Interpreted relative to the project directory, as for Project.file(Object). A string
that starts with file: is treated as a file URL.File. Interpreted relative to the project directory, as for Project.file(Object).URI or URL. The URL's path is interpreted as a file path. Currently, only
file: URLs are supported.
Collection, Iterable, or an array. May contain any of the types listed here. The elements of the collection
are recursively converted to files.FileCollection. The contents of the collection are included in the returned
collection.Callable. The call() method may return any of the types listed here.
The return value of the call() method is recursively converted to files. A null return value is
treated as an empty collection.null return value is treated as an empty collection.Task. Converted to the task's output files.TaskOutputs. Converted to the output files the related task.toString() value is treated the same way as a String, as for Project.file(Object).
Handling custom Objects has been deprecated and will be removed in the next version of Gradle.null return value is treated as an empty collection.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.
files in interface FileOperationsfiles in interface Projectpaths - The paths to the files. May be empty.public ConfigurableFileCollection files(Object paths, Closure closure)
ProjectCreates a new ConfigurableFileCollection using the given paths. The paths are evaluated as for Project.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.
files in interface FileOperationsfiles in interface Projectpaths - The contents of the file collection. Evaluated as for Project.files(Object...).closure - The closure to use to configure the file collection.public ConfigurableFileTree fileTree(Object baseDir)
ProjectCreates a new ConfigurableFileTree using the given base directory. The given baseDir path is evaluated
as for Project.file(Object).
Note: to use a closure as the baseDir, you must explicitly cast the closure to Object to force
the use of this method instead of Project.fileTree(Closure). Example:
fileTree((Object){ someDir })
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.
fileTree in interface FileOperationsfileTree in interface ProjectbaseDir - The base directory of the file tree. Evaluated as for Project.file(Object).public ConfigurableFileTree fileTree(Object baseDir, Closure closure)
ProjectCreates a new ConfigurableFileTree using the given base directory. The given baseDir path is evaluated
as for Project.file(Object). The closure will be used to configure the new file tree.
The file tree is passed to the closure as its delegate. Example:
fileTree('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.
fileTree in interface FileOperationsfileTree in interface ProjectbaseDir - The base directory of the file tree. Evaluated as for Project.file(Object).closure - Closure to configure the ConfigurableFileTree object.public ConfigurableFileTree fileTree(Map<String,?> args)
ProjectCreates 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.
fileTree in interface FileOperationsfileTree in interface Projectargs - map of property assignments to ConfigurableFileTree objectpublic ConfigurableFileTree fileTree(Closure closure)
ProjectCreates 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.
fileTree in interface FileOperationsfileTree in interface Projectclosure - Closure to configure the ConfigurableFileTree objectpublic FileTree zipTree(Object zipPath)
ProjectCreates a new FileTree which contains the contents of the given ZIP file. The given zipPath path is
evaluated as for Project.file(Object). You can combine this method with the Project.copy(groovy.lang.Closure)
method to unzip a ZIP file.
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.
zipTree in interface FileOperationszipTree in interface ProjectzipPath - The ZIP file. Evaluated as for Project.file(Object).public FileTree tarTree(Object tarPath)
ProjectFileTree which contains the contents of the given TAR file. The given tarPath path can be:
ResourceProject.file(Object)Unless custom implementation of resources is passed, the tar tree attempts to guess the compression based on the file extension.
You can combine this method with the Project.copy(groovy.lang.Closure)
method to untar a TAR file:
task untar(type: Copy) {
from tarTree('someCompressedTar.gzip')
//tar tree attempts to guess the compression based on the file extension
//however if you must specify the compression explicitly you can:
from tarTree(resources.gzip('someTar.ext'))
//in case you work with unconventionally compressed tars
//you can provide your own implementation of a ReadableResource:
//from tarTree(yourOwnResource as ReadableResource)
into 'dest'
}
tarTree in interface FileOperationstarTree in interface ProjecttarPath - The TAR file or an instance of Resource.public ResourceHandler getResources()
ProjectgetResources in interface FileOperationsgetResources in interface Projectpublic String relativePath(Object path)
ProjectReturns the relative path from the project directory to the given path. The given path object is (logically)
resolved as described for Project.file(Object), from which a relative path is calculated.
relativePath in interface FileOperationsrelativePath in interface Projectpath - The path to convert to a relative path.public File mkdir(Object path)
Projectmkdir in interface FileOperationsmkdir in interface Projectpath - The path for the directory to be created. Evaluated as for Project.file(Object).public boolean delete(Object... paths)
Projectdelete in interface FileOperationsdelete in interface Projectpaths - Any type of object accepted by Project.files(Object...)@Deprecated public org.gradle.api.tasks.Directory dir(String path)
mkdir(Object) instead.public void setTaskContainer(TaskContainerInternal taskContainer)
public Factory<AntBuilder> getAntBuilderFactory()
public void setAntBuilderFactory(Factory<AntBuilder> antBuilderFactory)
public DependencyHandler getDependencies()
ProjectDependencyHandlergetDependencies in interface ProjectProject.getConfigurations()public void setDependencyHandler(DependencyHandler dependencyHandler)
public ProjectEvaluationListener getProjectEvaluationBroadcaster()
getProjectEvaluationBroadcaster in interface ProjectInternalpublic void beforeEvaluate(Action<? super Project> action)
ProjectbeforeEvaluate in interface Projectaction - the action to execute.public void afterEvaluate(Action<? super Project> action)
ProjectafterEvaluate in interface Projectaction - the action to execute.public void beforeEvaluate(Closure closure)
ProjectAdds a closure to be called immediately before this project is evaluated. The project is passed to the closure as a parameter.
beforeEvaluate in interface Projectclosure - The closure to call.public void afterEvaluate(Closure closure)
ProjectAdds 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 further configure those child projects based on the state of the child projects after their build files have been run.
afterEvaluate in interface Projectclosure - The closure to call.public Logger getLogger()
ProjectReturns the logger for this project. You can use this in your build file to write log messages.
public StandardOutputCapture getStandardOutputCapture()
getStandardOutputCapture in interface ProjectInternalpublic LoggingManager getLogging()
ProjectLoggingManager which can be used to control the logging level and
standard output/error capture for this project's build script. By default, System.out is redirected to the Gradle
logging system at the QUIET log level, and System.err is redirected at the ERROR log level.getLogging in interface Projectpublic Object property(String propertyName) throws MissingPropertyException
ProjectReturns the value of the given property. This method locates a property as follows:
MissingPropertyExceptionproperty in interface ProjectpropertyName - The name of the property.MissingPropertyException - When the given property is unknown.public void setProperty(String name, Object value)
ProjectSets 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.
setProperty in interface Projectname - The name of the propertyvalue - The value of the propertypublic boolean hasProperty(String propertyName)
ProjectDetermines if this project has the given property. See here for details of the properties which are available for a project.
hasProperty in interface ProjectpropertyName - The name of the property to locate.public Map<String,?> getProperties()
ProjectReturns the properties of this project. See here for details of the properties which are available for a project.
getProperties in interface Projectpublic WorkResult copy(Closure closure)
ProjectCopySpec, which is then used to
copy the files. Example:
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'
}
}
copy in interface FileOperationscopy in interface Projectclosure - Closure to configure the CopySpecWorkResult that can be used to check if the copy did any work.public CopySpec copySpec(Closure closure)
ProjectCopySpec which can later be used to copy files or create an archive. The given closure is used
to configure the CopySpec before it is returned by this method.copySpec in interface FileOperationscopySpec in interface Projectclosure - Closure to configure the CopySpecpublic ExecResult javaexec(Closure closure)
ProjectJavaExecSpec.javaexec in interface ProcessOperationsjavaexec in interface Projectclosure - The closure for configuring the execution.public ExecResult exec(Closure closure)
ProjectExecSpec.exec in interface ProcessOperationsexec in interface Projectclosure - The closure for configuring the execution.public ServiceRegistryFactory getServices()
getServices in interface ProjectInternalpublic Module getModule()
getModule in interface DependencyMetaDataProviderpublic void apply(Closure closure)
ProjectConfigures this project using plugins or scripts. The given closure is used to configure an ObjectConfigurationAction which is then used to configure this project.
public void apply(Map<String,?> options)
ProjectConfigures this project using plugins or scripts. The following options are available:
from: A script to apply to the project. Accepts any path supported by Project.uri(Object).plugin: The id or implementation class of the plugin to apply to the project.to: The target delegate object or objects. Use this to configure objects other than the
project.For more detail, see ObjectConfigurationAction.
public AntBuilder ant(Closure configureClosure)
ProjectExecutes 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. See example in javadoc for Project.getAnt()
public void subprojects(Closure configureClosure)
ProjectConfigures the sub-projects of this project.
This method 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.
subprojects in interface ProjectconfigureClosure - The closure to execute.public void allprojects(Closure configureClosure)
ProjectConfigures this project and each of its sub-projects.
This method executes the given closure against this project and its sub-projects. The target Project
is passed to the closure as the closure's delegate.
allprojects in interface ProjectconfigureClosure - The closure to execute.public Project project(String path, Closure configureClosure)
ProjectLocates 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 Object configure(Object object, Closure configureClosure)
ProjectConfigures an object via a closure, with the closure's delegate set to the supplied object. This way you don't have to specify the context of a configuration statement multiple times.
Instead of:MyType myType = new MyType() myType.doThis() myType.doThat()you can do:
MyType myType = configure(new MyType()) {
doThis()
doThat()
}
The object being configured is also passed to the closure as a parameter, so you can access it explicitly if required:
configure(someObj) { obj -> obj.doThis() }
public Iterable<?> configure(Iterable<?> objects, Closure configureClosure)
ProjectProject.configure(Object,
groovy.lang.Closure) for each of the given objects.public void configurations(Closure configureClosure)
ProjectConfigures the dependency configurations for this project.
This method executes the given closure against the ConfigurationContainer
for this project. The ConfigurationContainer is passed to the closure as the closure's delegate.
ConfigurationContainerconfigurations in interface ProjectconfigureClosure - the closure to use to configure the dependency configurations.public void repositories(Closure configureClosure)
ProjectConfigures the repositories for this project.
This method executes the given closure against the RepositoryHandler for this project. The RepositoryHandler is passed to the closure as the closure's delegate.
repositories in interface ProjectconfigureClosure - the closure to use to configure the repositories.public void dependencies(Closure configureClosure)
ProjectConfigures the dependencies for this project.
This method executes the given closure against the DependencyHandler for this project. The DependencyHandler is passed to the closure as the closure's delegate.
DependencyHandlerdependencies in interface ProjectconfigureClosure - the closure to use to configure the dependencies.public void artifacts(Closure configureClosure)
ProjectConfigures the published artifacts for this project.
This method executes the given closure against the ArtifactHandler for this project. The ArtifactHandler is passed to the closure as the closure's delegate.
Example:
configurations {
//declaring new configuration that will be used to associate with artifacts
schema
}
task schemaJar(type: Jar) {
//some imaginary task that creates a jar artifact with the schema
}
//associating the task that produces the artifact with the configuration
artifacts {
//configuration name and the task:
schema schemaJar
}
public void buildscript(Closure configureClosure)
ProjectConfigures the build script classpath for this project.
The given closure is executed against this project's ScriptHandler. The ScriptHandler is
passed to the closure as the closure's delegate.
buildscript in interface ProjectconfigureClosure - the closure to use to configure the build script classpath.public Task task(String task)
ProjectCreates a Task with the given name and adds it to this project. Calling this method is equivalent to
calling Project.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(String task, Closure configureClosure)
ProjectCreates 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 Task task(Map options, String task)
ProjectCreates 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. | DefaultTask |
"overwrite" | Replace an existing task? | false |
"dependsOn" | A task name or set of task names which this task depends on | [] |
"action" | A closure or Action to add to the
task. | null |
"description" | A description of the task. | null |
"group" | A task group which this task belongs to. | 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 options, String task, Closure configureClosure)
ProjectCreates 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 Project.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 Object passThrough(Object object)
public <T> NamedDomainObjectContainer<T> container(Class<T> type)
ProjectCreates a container for managing named objects of the specified type. The specified type must have a public constructor which takes the name as a String parameter.
All objects MUST expose their name as a bean property named "name". The name must be constant for the life of the object.
public <T> NamedDomainObjectContainer<T> container(Class<T> type, NamedDomainObjectFactory<T> factory)
ProjectCreates a container for managing named objects of the specified type. The given factory is used to create object instances.
All objects MUST expose their name as a bean property named "name". The name must be constant for the life of the object.
public <T> NamedDomainObjectContainer<T> container(Class<T> type, Closure factoryClosure)
ProjectCreates a container for managing named objects of the specified type. The given closure is used to create object instances. The name of the instance to be created is passed as a parameter to the closure.
All objects MUST expose their name as a bean property named "name". The name must be constant for the life of the object.
public ExtensionContainer getExtensions()
ProjectgetExtensions in interface ExtensionAwaregetExtensions in interface ProjectCopyright © 2013. All rights reserved