Gradle Programming TODEPLETE: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 6: Line 6:


{{Internal|Groovy#Overview|Groovy}}
{{Internal|Groovy#Overview|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'
<syntaxhighlight lang='groovy'>
println project
</syntaxhighlight>
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'>
println rootProject
</syntaxhighlight>
For a sub-project, a reference to the parent project can be obtained by invoking "project.getParent()", or simply 'parent'.
<syntaxhighlight lang='groovy'>
println parent
</syntaxhighlight>


=Recipes=
=Recipes=

Revision as of 06:33, 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

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