To validate a task before any task has been executed, you can use the ‘taskGraph.whenReady’ callback:
gradle.taskGraph.whenReady { graph ->
if (graph.hasTask(makerpm) && !hasRpmbuild()) {
throw new GradleException("rpmbuild does not exist")
}
}