Exec task with Provider-valued executable and Provider-valued args

I’m working on a plugin that takes some of its configuration from an extension. The extension uses Propertys/Providers in order to ensure lazy evaluation of the arguments.

I’m trying to determine how to configure my Exec task using Providers coming from my extension, but at configuration time the Providers have not yet observed extension values and the task configuration thus fails to correctly configure my task, so the task fails to run.

What’s the correct practice for defining a custom Exec task that takes the executable and arguments to the executable from lazily defined Provider values?

A lot of the core Gradle tasks have not yet been updated to work with providers, as you are experiencing.

Perhaps there’s a better way, but at this point I would probably create my own wrapper task class that does support providers. This class’s @TaskAction method would then use the project.exec method to perform the execution as the previous Exec task did.