Vlastimil Brecka
07/03/2026, 10:26 AM.properties that's easily read by gradle? the flatness of properties tripes me up when it becomes largerVampire
07/03/2026, 10:28 AMVlastimil Brecka
07/03/2026, 1:25 PMVampire
07/03/2026, 2:26 PMkaml or SnakeYAML / SnakeYAML KMPVampire
07/03/2026, 2:29 PMVlastimil Brecka
07/03/2026, 2:32 PMVampire
07/03/2026, 3:05 PMVlastimil Brecka
07/03/2026, 3:07 PMVampire
07/03/2026, 3:12 PMVlastimil Brecka
07/03/2026, 3:13 PMVampire
07/03/2026, 3:13 PMour-fancy-config.yaml in the consumer project and in your convention plugins you parse that file with the service and provide the result from there directly, or through an extension.Vampire
07/03/2026, 3:14 PMwould you however model the exposed "thing" which is hierarchical, as a data class and inside it references to other data classes
or should be this provider of providers etcNot fully sure without more context, but I guess just data classes would be fine
Vampire
07/03/2026, 3:15 PMVlastimil Brecka
07/03/2026, 3:15 PMconfig.appA.baseApiUrl=..
config.appB.baseApiUrl=..
config.appC.baseApiUrl=..
something like this is the source
data class Config(appA: AppA, appB: AppB, appC: AppC)
data class AppA(baseApiUrl: String)
...Vampire
07/03/2026, 3:15 PMproviders.provider { ... } then if he want's to do it only when needed.Vlastimil Brecka
07/03/2026, 3:16 PMappA be a Provider insteadVampire
07/03/2026, 3:16 PMVampire
07/03/2026, 3:16 PMVlastimil Brecka
07/03/2026, 3:17 PMVlastimil Brecka
07/03/2026, 3:18 PMProvider<Properties> customProperties = providers
.fileContents(customPropertiesFile)
.asText
.map { text ->
def properties = new Properties()
properties.load(new StringReader(text))
return properties
}
this means any time I access this, it reads the file, i.e. does IO?Vampire
07/03/2026, 3:23 PM.map is evaluated each time you query the value, yes.
Unless you for example make a property to which you set this provider as value and then call finalizeValueOnRead() on it, then it is only evaluated once.
Basically a poor-man's version of the memoizing providers requested at github.com/gradle/gradle/issues/25550.
But that's anyway not what I recommended.
I recommended having a build service that does the parsing in its constructor,
because the scope of a build service is one build execution.
So you do the parsing once and then have alle the values accessible from the service or if you need them conveniently in the build scripts and anyway have some convention plugin applied everwhere then additionally an extension that gets its values fed from the build serivice.Vlastimil Brecka
07/03/2026, 3:24 PMVampire
07/03/2026, 3:24 PMVampire
07/03/2026, 3:24 PMVlastimil Brecka
07/03/2026, 3:25 PMVampire
07/03/2026, 3:26 PMVampire
07/03/2026, 3:27 PMabout the rereading, is that a problem or not? i mnot sure how should that play with configuration cache, make me think that changing props doesnt trigger invalidation?If you parse the file at configuration phase, it becomes a CC input and thus will invalidate the CC entry if the file was changed. If you only parse the file at execution phase, it does not influence CC state and thus would not be a CC input and the CC entry could be reused.
Vlastimil Brecka
07/03/2026, 3:28 PMVampire
07/03/2026, 3:28 PMVampire
07/03/2026, 3:29 PMaaand should it? 😄 i dont know, its just constants I feed into android's buildconfig mostlyI don't do Android, so no idea. But probably yes, you probably configure some task with those values, so different file content means different task config, so the CC state cannot be reused and needs to be reevaluated.
Vlastimil Brecka
07/03/2026, 3:33 PM.get() the whole config into a local variable and reference that, i.e. not completely requerying, but if another build script tries to do that, i.e 2nd io, is that...fine?Vampire
07/03/2026, 3:37 PMVlastimil Brecka
07/03/2026, 3:39 PMVampire
07/03/2026, 3:59 PMVampire
07/03/2026, 4:00 PMVampire
07/03/2026, 4:01 PMVampire
07/03/2026, 4:03 PMval value1 = doCostlyCalculation().getValue1()
val value2 = doCostlyCalculation().getValue2()
vs.
val values = doCostlyCalculation()
val value1 = values.getValue1()
val value2 = values.getValue2()Vampire
07/03/2026, 4:03 PM