Gradle Programming TODEPLETE

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

Groovy

Groovy

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

Recipes

Task that Prints the Execution Classpath

Print the Runtime Classpath

Obtain and Use Gradle Version in build.gradle

Gradle Object - Gradle Version