I am trying to understand how Gradle works, reading through the documentations on Build Environment.
After reading the whole page I am confused regarding the nature of properties, types of properties and the relationship between them. I have searched through stackoverflow and I have ran tests before posting here, I would really appreciate any help or answers because I am just completely stuck… The more I re-read the page, the more confused I got .
Can someone please explain in detail, how the concepts and terms 1.Gradle Properties, 2.System Properties and 3.Project Properties relate to each other, and how are they structured/organized?
Some questions I have, for example, are System Properties and Project properties part of Gradle properties?
- On the page’s context menu, Gradle Properties, Project Properties and System Properties are clearly arranged as siblings
- From
gradle --help
, the only options available that specifies properties are-D
and-P
, which are for System and Project properties respectively. Gradle Properties is not seen here as an option.
Here I would presume that System Properties and Project properties ARE “children/supersets” of Gradle properties,
i.e. system/project “extends” or “implements” gradle properties.
However, on Gradle properties, quote:
The final configuration taken into account by Gradle is a combination of all Gradle properties set on the command line and your
gradle.properties files. If an option is configured in multiple locations, the *first one* found in any of these locations wins:
* command line, as set using
-D.
Here I thought, why isn’t -P
mentioned? -D
only configures System Properties, so Project Properties is handled differently?
Next, when trying to retrieve a property in a build script, we could use exist methods under ProviderFactory.java
like:
project.providers.gradleProperty(key)
project.providers.systemProperty(key)
A method named “projectPropety” does NOT exist, but the method gradleProperty
can retrieve Project Properties passed down through command line’s -P
option.
What is going on? I am just stuck and confused, are Project Properties even Gradle Properties?
Again I would really appreciate any help, thank you in advance!