Gradle Programming TODEPLETE: Difference between revisions
(→Tasks) |
|||
Line 33: | Line 33: | ||
=Tasks= | =Tasks= | ||
{{Internal|Gradle Task|Gradle Task}} | |||
==Obtaining a Task Reference== | ==Obtaining a Task Reference== |
Revision as of 06:59, 24 February 2019
Internal
Groovy
Projects
Inter-Project "Communication"
The Project is the main API to use to interact with Gradle, so a great deal of custom configuration can be achieved getting a hold of a project reference and reading state from it or invoking into it from the build.gradle files. The reference to the current project can be obtained by using getProject() in the corresponding build.gradle file, which is equivalent with invoking 'project'
println project
A project reference can be used to get references to other Projects in the tree and thus navigate the hierarchy.
For all projects in the hierarchy, the reference to the root project can be obtained by invoking 'project.getRootProject()', or simply 'rootProject'.
println rootProject
For a sub-project, a reference to the parent project can be obtained by invoking 'project.getParent()', or simply 'parent'.
println parent
Tasks
Obtaining a Task Reference
Task task = project.getTasksByName("build", false).asList().get(0)