Gradle Properties - Runtime and Project Configuration: Difference between revisions
Line 16: | Line 16: | ||
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 build objects can be read from [[settings.gradle]] or [[build.gradle]] 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 build objects can be read from [[settings.gradle]] or [[build.gradle]] scripts via dedicated accessors. | ||
<span id='Project_State'></span>A project exposes | <span id='Project_State'></span>A project exposes '''coordinate properties''' such as [[Gradle_Project_Coordinates,_State_and_Configured_Properties#Name|name]], [[Gradle_Project_Coordinates,_State_and_Configured_Properties#Group|group]] and [[Gradle_Project_Coordinates,_State_and_Configured_Properties#Version|version]], various other '''state properties''' such as the [[Gradle_Project_Coordinates,_State_and_Configured_Properties#Description|description]], [[Gradle_Project_Coordinates,_State_and_Configured_Properties#Path|path]], and '''externally configured properties''' that come from [[gradle.properties#Overview|gradle.properties]] file hierarchy or [[Gradle_Project_Coordinates,_State_and_Configured_Properties#-P_Command-Line_Options|-P command line options]]. More details about accessing the project state and externally-configured properties are available in: {{Internal|Gradle_Project_Coordinates,_State_and_Configured_Properties|Gradle Project Coordinates, State and Configured Properties}} | ||
<span id='Task_State'></span>A task also exposes its state ([[Gradle_Task#Task_Name|name]], [[Gradle_Task#Description|description]], whether it is [[Gradle_Task#Enabled|enabled]] or not) through getters and DLS elements. | <span id='Task_State'></span>A task also exposes its state ([[Gradle_Task#Task_Name|name]], [[Gradle_Task#Description|description]], whether it is [[Gradle_Task#Enabled|enabled]] or not) through getters and DLS elements. |
Revision as of 06:45, 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 options, system properties, settings.gradle and build.gradle extra properties, gradle.properties file properties and environment variables. All these configuration elements are provided externally and injected into the build and various model object instances.
It is also possible to define properties, referred to as extra properties, in settings.gradle and build.gradle scripts and pass configuration around between different elements of the build.
Since build scripts may include executable code, it is also possible to use local variables, which are a feature of the underlying Groovy language.
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 build objects can be read from settings.gradle or build.gradle scripts via dedicated accessors.
A project exposes coordinate properties such as name, group and version, various other state properties such as the description, path, and externally configured properties that come from gradle.properties file hierarchy or -P command line options. More details about accessing the project state and externally-configured properties are available in:
A task also exposes its state (name, description, whether it is enabled or not) through getters and DLS elements.