Philip W
09/01/2026, 9:29 AMProperties files, and I want to pass these properties to a `MapProperty<String, String>`:
`val propertiesAsMapProvider = providers.fileContents(
writePropertiesToFile.flatMap { it.output },
).asText.map {
it.byteInputStream().use {
Properties().apply { load(it) } as Map<String, String>
}
}
This looses the task dependencies...Philip W
09/01/2026, 9:39 AMval propertiesAsMapProvider = writePropertiesToFile.flatMap { it.output }.map {
it.asFile.inputStream().use {
Properties().apply { load(it) } as Map<String, String>
}
}Anze Sodja
09/01/2026, 12:44 PMRegularFileProperty and read a properties file in a task?Philip W
09/01/2026, 1:01 PMPhilip W
09/04/2026, 4:03 AMAnze Sodja
09/04/2026, 6:05 AMMapProperty<String, String> makes sense. So what you do probably makes sense if is fast enough. If reading these properties is slow or file is really big and reading into memory is a bottlenect then it makes sense to add another property that is a RegularFileProperty . But I think normally properties files are small and what you do looks fine.
> But IMHO Gradle lacks a way to transform a task output (file, files or directories) to a task input (any Property), ideally with classpath isolation transformations to not pollute your build script when you need a complex operation.
Do you have any example what would be benefit compared to just using map? I know that having any property type as an output is a desired feature, e.g. @Output Property<String> . This could help with some boilerplate. And then if you would want to transform a file to a String or Map you would just write a task that does that and outputs Property<String>.
Note that In the end Gradle would still need to write this output to a file or a database, since output have to persist even if daemon is stopped, but at least user won't need to deal with it.Philip W
09/04/2026, 6:32 AMis a bottlenect then it makes sense to add another property that is a RegularFileProperty . But I think normally properties files are small and what you do looks fine.But as a task author, I don't know how other users will populate the values. In my example, I use a 3rd party tasks that exposes a
MapProperty<String, String> and I wrote a (local) task to produce the values that will be passed to the MapProperty. I would never expect to ask the 3rd party plugin to include my use-case and change their tasks.
Do you have any example what would be benefit compared to just using map?If the output is a Json, protobuf file, you cannot read it without polluting the buildscript classpath. Also, you often need Java Beans classes for these use-cases. But yeah, I would love to see
@Output for all Gradle managed types.Vampire
09/04/2026, 9:30 AMPhilip W
09/04/2026, 4:15 PM