Grails Detect if a Plugin is Installed
Asked Answered
S

3

8

Is there a way in Grails to Detect that a plugin is installed. For example I need to know if the "Acegi" plugin is installed. If it is then I can run different Code. If the plugin is not installed (which is a viable option) then I can run different code.

Thanks in Advance.

Sezen answered 31/5, 2010 at 3:27 Comment(0)
F
8

You can use the plugin manager for this:

import org.codehaus.groovy.grails.plugins.PluginManagerHolder

if (PluginManagerHolder.pluginManager.hasGrailsPlugin('acegi')) {
   ...
}
Froemming answered 31/5, 2010 at 4:5 Comment(0)
P
3

You can use <plugin:isAvailable> and <plugin:isNotAvailable> tags.

Example using OP's acegi plugin:

<plugin:isAvailable name="acegi">
    You have acegi installed!
</plugin:isAvailable>
Prenotion answered 1/9, 2014 at 13:34 Comment(0)
H
3

Update for Grails 2.4+

Note that the specific holder classes such as PluginManagerHolder have all been deprecated for several versions of Grails, and removed in Grails 2.4. They have been replaced by a single grails.util.Holders class providing access to all the various application-wide objects through a single access point.

import grails.util.Holders

if (Holders.pluginManager.hasGrailsPlugin('acegi')) {
   ...
}
Habitant answered 17/2, 2015 at 11:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.