Obtain Grails plugin version at runtime

余生颓废 提交于 2019-12-08 11:52:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!