I have a consumer task that accepts input: `Provid...
# community-support
z
I have a consumer task that accepts input:
Provider<String>
, which needs to be generated by a producer task. For
./gradlew consumerTask
- I’m seeing:
Copy code
/Users/zak/Development/git/myproject/build/output.txt (No such file or directory)
What am I doing wrong?
e
I think Gradle is capturing the configuration of the tasks before executing any of them, which makes sense, but is problematic for you
my first thought was to try
Copy code
this.input = providers.fileContents(producerTask.flatMap { it.outputFile }).asText.orElse("")
but it falls back to
""
at configuration time, so it never gets the real output at runtime
it would work out if you could change the consumer to `@get:InputFile abstract val inputFile: RegularFileProperty`… but if you can't, then I'm not sure
m
That looks like a bug in Gradle, honestly. It works for me without the configuration cache. When I change
map
to
flatMap {it.outputFile}.map {...}
I'm hitting https://github.com/gradle/gradle/issues/29335, and there changing from
Provider
to
RegularFileProperty
helps. I'm not sure why CC decided to reduce the
producerTask.map
to value, will investigate it further.
z
thanks! I filed this issue: `@OutputFile RegularFileProperty` to `@Input Provider<String>` throws FileNotFoundException with the configuration cache on
oops, I think we have duplicates https://github.com/gradle/gradle/issues/29639