I have task that is supposed to call a task that is defined in another build.gradle file. However, that task may not exist in the other gradle file. The two gradle files don’t know anything about each other. If ‘taskThatMayNotExist’ doesn’t exist, I want the task to just quietly skip it, but if it does exist, then go ahead and call it. I’ve seen examples with tasks.getByPath and getByName, but those seem to only work if the task belongs to the same project.
task blah(type: GradleBuild) {
buildFile = directory+ '/build.gradle'
dir = directory
tasks = ['taskThatMayNotExist']
}
So my simple question is how to determine if the build.gradle located at the buildFile path actually contains the task ‘taskThatMayNotExist’?
I’m very much new to Gradle and I’ve been stuck on this for a while. I would really appreciate any help. Thanks.