How can I list all grails plugin controllers / services

How can I list all the controllers / services of the grails plugin. Or How to find out the name pluin for a given GrailsApplication class.

+4
source share
2 answers

Plugin artifacts are annotated with the GrailsPlugin annotation to add metadata about their source. So you can use this to determine if there is a controller / service / etc. from application or plugin:

 import org.codehaus.groovy.grails.plugins.metadata.GrailsPlugin for (type in ['controller', 'service']) { for (artifactClass in ctx.grailsApplication."${type}Classes") { def clazz = artifactClass.clazz def annotation = clazz.getAnnotation(GrailsPlugin) if (annotation) { println "$type $clazz.name from plugin '${annotation.name()}'" } else { println "$type $clazz.name from application" } } } 
+10
source

In the newly created Grails application, the grails-app / views / index.gsp application has the following:

 <g:each var="c" in="${grailsApplication.controllerClasses.sort { it.fullName } }"> <li class="controller"><g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link></li> </g:each> 

You can get services in a similar way.

0
source

All Articles