Callback on each task in the task graph that is invoked when task graph ready

We have some tasks that run at the end of a rather long build. These tasks might fail if some conditions are not met, e.g. an expected file is missing somewhere, etc. It is problematic to wait for the long build to complete and only learn at the very end that a file is missing (or something else).

It would be very helpful if every task can implement a callback that is invoked when the task graph is ready, but only if the task is actually part of the task graph. The task could then check the pre-conditions and fail the build if they are not met?

Any thoughts on this? Already achievable today?

Regards, Etienne

Ideally, Gradle would provide an easy way for a task to validate its own configuration. In terms of API, an annotation-based approach comes to mind. Although it would make sense to have this baked in, it should be possible to implement this as a plugin today (based on ‘taskGraph.whenReady {}’).