David Göransson
05/16/2025, 7:05 AMgradle.properties
is not the way to go since we want it to be checked it, local.properties
is used by AGP and not recommended to be used by others even though a lot of apps do utilize it, also it does not solve the problem of loading variables, from e.g Environment.
As I understand it we basically have to write our own function that are able to fetch the properties from all the different places (e.g enviroment, gradle arguements or properties file). Feels like there should be some standardized way to do this that I'm missing?David Göransson
05/16/2025, 7:12 AMfun getCustomProperty(name: String, defaultValue: String): String =
System.getenv(name)
?: rootProject.properties.getOrDefault(name, null) as? String
// Some function get the a custom property from our x.properties file
?: customProperties(rootProject.projectDir, providers).getProperty(name)
?: defaultValue
Vampire
05/16/2025, 9:06 AMgradle.properties
.
User-specific values can be in <GRADLE_USER_HOME>/gradle.properties
which overwrite the project ones.
You can also use gradle arguments on the commandline, system properties, or environment variables to overwrite those.David Göransson
05/16/2025, 9:32 AMDavid Göransson
05/16/2025, 9:41 AMgradle.properties
, then the defaults can neatly be kept in one place.Vampire
05/16/2025, 9:43 AMproviders.gradleProperty
will not see the values from those additional files, but only consumers that use the "traditional" project.getProperty
and friends as those consider the extra properties for overwriting Project properties.David Göransson
05/16/2025, 9:47 AM