Gradle Programming TODEPLETE: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 17: Line 17:
A project reference can be used to get references to other Projects in the tree and thus navigate the hierarchy.
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'.  
For all projects in the hierarchy, the reference to the root project can be obtained by invoking 'project.getRootProject()', or simply 'rootProject'.  


<syntaxhighlight lang='groovy'>
<syntaxhighlight lang='groovy'>
Line 23: Line 23:
</syntaxhighlight>
</syntaxhighlight>


For a sub-project, a reference to the parent project can be obtained by invoking "project.getParent()", or simply 'parent'.  
For a sub-project, a reference to the parent project can be obtained by invoking 'project.getParent()', or simply 'parent'.  


<syntaxhighlight lang='groovy'>
<syntaxhighlight lang='groovy'>

Revision as of 06:37, 24 February 2019

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