Autowiring task input properties

Auto-wiring in Gradle allows Buildable FileCollections declared as task inputs to be automatically added to the task’s dependencies. However, this doesn’t appear to be the case for Buildable input properties.

I have a property that is an input to multiple tasks, and is expensive to calculate. So I’d like to add a task to calculate it, and have any tasks which require it as input automatically depend on the calculation task. Would it not be possible to extend the auto-wiring feature to include input properties in order to allow for this?

1 Like

Hey Rowan,

with Rule based configuration model you’re able to do this as modelling this input property as a model. Have a look at the https://docs.gradle.org/current/userguide/userguide_single.html#software_model

Apart from this there is no support for this atm in Gradle. If you don’t use rule based configuration the best chance to do this IMO is to calculate this input as a separate task and let other tasks depend on it.

Hi Rene,

Thanks for the advice.

I’m quite familiar with rule based configuration, but less so with the new software model. Are you suggesting that the input property type could be a separate software model type, like ConfigurationSpec or BinarySpec? If so, would you be able to give an example of how best to achieve this? I can’t find any documentation on creating new software model base types anywhere.

Thanks