Pass a directory which is not created yet in configuration step

task doSomething (type: ProduceFilesTaskType) {
   outDir = file("$projectDir/some/files")

task mytask (type: ConsumerFilesTaskType) {
   fileList = file("$doSomething.outDir/somefolders/").listFiles().toList() // null pointer exception

The ConsumeFilesTaskType in above example takes in a List<File> fileList which I am producing with first task. Now because these files don’t exist yet, gradle fails at configuration stage with error Cannot invoke method toList() on null object

What should I do?

Do you control the implementation of ConsumerFilesTaskType such that you can modify it?

No, I don’t. This is the reason I am asking for a way.