问题
Is it possible to obtain version of a specific Grails plugin at runtime, let say in Bootstrap class? Or more generically, how to query loaded plugins from the parent Grails applications and obtain their names and version numbers?
回答1:
The simplest way is to interact with the pluginManager bean.
class BootStrap {
def pluginManager
def init = { servletContext ->
// retrieve them all...
pluginManager.allPlugins.each { plugin ->
println "Plugin: ${plugin.name}, Version: ${plugin.version}"
}
// retrieve a specific plugin...
def hibPlugin = pluginManager.getGrailsPlugin('hibernate4')
println "Hibernate Plugin Version: ${hibPlugin.version}"
}
}
来源:https://stackoverflow.com/questions/24665629/obtain-grails-plugin-version-at-runtime