This section explores the different types of options, arguments, properties, and variables in Gradle’s build environment, discussing their differences, overriding relationships, and usage techniques.
The most direct way to pass parameters in Gradle is through Command Line Interface (CLI) options. These options can be grouped into five categories, each extensively covered in the official Gradle documentation:
After getting a general idea, the following articles can deepen your understanding, focusing on debugging and performance monitoring:
These articles emphasize debugging capabilities for plugins and scripts, noting that script debugging is still evolving.
Some performance-related switches, in addition to CLI syntax, also correspond to keys in gradle.properties
. This file is Gradle’s default location for various environment parameters. Regularly used parameters can be set here to avoid extensive CLI configurations. Its definition and the overriding relationship with CLI parameters are documented as follows:
gradle.properties
includes system properties, environment variables, project properties, and various plugin properties. AGP and Kotlin’s properties can be further explored in these articles:
The last article from the previous section already shows how to manage dependency versions using gradle.properties
. Here, we list some more generic custom parameter inputs and reading methods, focusing on understanding the extra
and by project
delegation reading methods:
Additionally, a common issue arises when using buildscript{}
with ext
or extra
:
--scan
) regularly, especially when encountering build issues. This proactive approach helps in quickly identifying and resolving problems.extra
across modules is not always convenient due to the loose coupling nature of keys as strings. In many cases, it’s advisable to utilize buildSrc
combined with scripts for sharing data. This method provides a more structured and maintainable approach to managing shared configurations and dependencies across different modules in a Gradle project.