@Validate needs a little more clarification

Continuing the discussion from New model confusion:

It is pretty clear what the purpose of @Validate is: Validate that certain criteria / contracts are met with settings. The examples in the Gradle docs all use assert. Is this the best approach or should a specific exception rathe rbe thrown?

Dealer’s choice in my opinion. In conjunction with Groovy using assert gives you the benefit of power assertions in the error message. In any case I would at least provide a message if using assert, otherwise throw an exception with an appropriate message. There is no functional difference between the two, as in, there’s no special type of exception that should be thrown that we look for to react differently to these types of errors.

I’ll expand on this to say that this applies to custom build logic in Gradle in general. Throw whatever exception you like. The only exception (no pun intended) to this is StopActionException and StopExecutionException.