I have a custom ValueSource that takes an Configur...
# community-support
p
I have a custom ValueSource that takes an ConfigurableFileCollection as a parameter. Does Gradle support task dependencies for ValueSources?
Copy code
internal abstract class GripEnvValueSource : ValueSource<Map<String, String>, Parameters> {
    interface Parameters : ValueSourceParameters {
        val apiFiles: ConfigurableFileCollection
    }
    
  override fun obtain(): Map<String, String> = buildMap {
        for (apiFile in parameters.apiFiles) {
            for (createdFlow in Json.decodeFromString<List<CreatedFlow>>(apiFile.readText())) {
    }}}
When I wire the apiFiles like this:
Copy code
providers.of(GripEnvValueSource::class) {
        parameters {
            apiFiles.from(configurations.foo)
        }
    }
I still get the error when consuming the ValueSource: File does not exist
v
If you use a value source, then probably because you want to determine something that should count as CC input right?
That means the value is determined at configuration time
See where that leads to?
p
I see 😐
πŸ™‚ 1
I β€žjustβ€œ want to simplify my task by moving some code to valuesources 🫠
v
So you are not using the value source for CC? How do you use it? I might not have understood the use-case right yet
p
Not explicitly, but it is a task input so CC relevant. The idea was to create a task accepting a ListPropertyString and you can use a value source to configure the list via a file (that is a outcome of another task).
So as a workaround I will move the code back to the task
And use the files as input.
v
Yeah, I don't think it would work, especially not with CC. IIRC, when CC is persisted all the providers that are task state are evaluated and the result persisted. So the task outputs would not yet be available.
p
yeah, after talking about it, it sounds impossible πŸ¦†
πŸ‘Œ 1
m
Does Gradle support task dependencies for ValueSources?
No, no task dependencies at the moment.
to configure the list via a file (that is a outcome of another task).
It isn't clear why you need a ValueSource for that. When dealing with task outputs, you can have something like
producerTaskProvider.flatMap { it.outputFileProvider }.map { readStringList(it) }
and use it as a value for the
ListProperty
of the consuming task. It will bring task dependencies along. CC is aware of task outputs and won't evaluate these providers when storing the cache, but will record the transformation instead. The only thing to be mindful of is https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache:not_yet_implemented:accessing_top_level_at_execution when declaring
readStringList
.
❀️ 1
til 1
p
The reading and parsing of the file requires another library that should not be part of the plugin classpath but using an isolated classpath from a workerexecutor, but there is also no worker executor option for a valuesource yet.