During compilation, an AST transformation adds an empty method for action methods with arguments. This is annotated with the grails.web.Action
annotation which has a commandObjects
attribute containing a Class[]
array of the classes of command objects and regular method argument types.
So you can loop through all of the controllers in the application, and find all annotated methods:
import grails.web.Action
for (cc in grailsApplication.controllerClasses) {
for (m in cc.clazz.methods) {
def ann = m.getAnnotation(Action)
if (ann) {
String controller = cc.logicalPropertyName
String action = m.name
Class[] argTypes = ann.commandObjects()
println "${controller}.$action(${argTypes*.name.join(', ')})"
}
}
}