Input validation for extensions


(Yves Müller) #1

My gradle plugin adds an extension containg several string fields which needs to be validate. I’d like to validate them all in one place and therefore added an validate method to the extension. What is the propper place to call this function? Is there some general scheme for validation or some hook that will be called once the build.gradle has been read / executed?


(Gary Hale) #2

The project.afterEvaluate() hook is probably what you want. See http://www.gradle.org/docs/current/dsl/org.gradle.api.Project.html#org.gradle.api.Project:afterEvaluate(groovy.lang.Closure).