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" } } }
source share