Gradle Properties - Runtime and Project Configuration: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 13: Line 13:
<span id='Gradle_Extra_Properties'>It is also possible to define properties in the build scripts and pass configuration around between different elements of the build. Those properties are named "extra properties".  
<span id='Gradle_Extra_Properties'>It is also possible to define properties in the build scripts and pass configuration around between different elements of the build. Those properties are named "extra properties".  
{{Internal|Gradle Extra Properties|Gradle Extra Properties}}
{{Internal|Gradle Extra Properties|Gradle Extra Properties}}
Since build scripts may include executable code, it is also possible to use local variables, which are a feature of the underlying Groovy language.
<span id='Gradle_Local_Variables'></span>Since build scripts may include executable code, it is also possible to use local variables, which are a feature of the underlying Groovy language.
{{Internal|Gradle Local Variables|Gradle Local Variables}}
{{Internal|Gradle Local Variables|Gradle Local Variables}}
The external configuration and extra properties become part of the state of various objects of the build, such as projects or tasks. The state of the build's objects can be read from the build scripts via dedicated accessors.  
The external configuration and extra properties become part of the state of various objects of the build, such as projects or tasks. The state of the build's objects can be read from the build scripts via dedicated accessors.  

Revision as of 03:20, 5 October 2020

External

Internal

Overview

"Properties" in this context represent external configuration elements passed to a Gradle build to modify the behavior of the Gradle runtime itself, or the behavior of tasks being executed by various projects that are part of the build. Gradle supports many kinds of "properties": configuration can be passed as command line flags, system properties, Gradle properties, environment variables and project properties. All these configuration elements are provided externally and injected into the build.

Gradle Command Line Flags
Gradle System Properties
Gradle Properties
Gradle Environment Variables
Gradle Project Properties

It is also possible to define properties in the build scripts and pass configuration around between different elements of the build. Those properties are named "extra properties".

Gradle Extra Properties

Since build scripts may include executable code, it is also possible to use local variables, which are a feature of the underlying Groovy language.

Gradle Local Variables

The external configuration and extra properties become part of the state of various objects of the build, such as projects or tasks. The state of the build's objects can be read from the build scripts via dedicated accessors.

A project exposes coordinates such as name, group and version, then various other state elements such as the description, path, and many more. More details about accessing the state of the project is available in:

Gradle Project Coordinates and State Properties

A task also exposes its state through getters and DLS elements.

TO DEPLETE

Gradle_Variables_and_Properties