Are there standard exceptions that tasks should throw for things like a required configuration item not being set?

For things like missing configuration settings it seems like it would be good for a task to have some standard exceptions so that the user can be presented with something more helpful than a stack trace. Are there such things already?

In particular, what should a task in my plugin throw if a required configuration item is not present and it is not possible to have a sensible default?

It appears that the Application plugin for example does something like this. If you do not set a main class, it prints:

No value has been specified for property ‘mainClassName’.

and fails. But it is not clear to me how this happens. Maybe it is because it is using the convention system for configuration. I am currently using the extension system as I thought that was the future. Can something similar be done with Extensions?

thanks, Philip

Currently there is no specific Exception for that. But using org.gradle.api.GradleException with a meaningful message should do the trick. Gradle takes the message of an Exception and uses this message in its build failed output.

cheers, René

There is ‘javadoc:org.gradle.api.InvalidUserDataException’, which you should use for this.