Lazily set arguments for Exec tasks

Is it possibly somehow to lazily set the command line arguments for an Exec task?

I’ve tried using properties but with no success. Can argumentProviders be used for this?

Yes, argumentProviders should be evaluated lazily afair.

Unfortunately it seems to be read only. I get:

> Cannot set the value of read-only property 'argumentProviders' for task ':cmdTest' of type org.gradle.api.tasks.Exec.

I will work around this from the process that’s being executed instead

You don’t set it, you get it and then adapt it, e.g. like argumentProviders.add(...)

Yes that works. Thank you