Disable task from extension

I have an extension that has a boolean parameter, something like this:

‘’’ myExtension {

myTaskEnabled false } ‘’’

My plugin creates a “myTask” which should be enabled/disabled based on “myTaskEnabled” in the extension. Is it okay to use convention mapping to map task.enabled to this value, or should I do this differently?

Thanks

The other option is to use ‘onlyIf’. I tend to think that is preferable since it supports multiple predicates.

myTask {

onlyIf {

project.myExtension.myTaskEnabled

}

}