简体   繁体   中英

How to configure a grails plugin from another grails plugin

I am trying to write a plugin which I can reuse in several grails applications. The plugin should basically be a wrapper for the spring security core and the ldap plugin.

Which means it should contain:

  • The domain classes for the user/roles
  • The configuration for spring security (the mapping to these domain classes, some default URL access role configuration)

My problem is that i can't get the configuration inside my plugin working. I am confused by the examples I found so far: sometimes I read that the configuration should simply go to "Config.groovy" however grails docs state that this file isn't part of a plugin in the end. In some examples it says that you have to put the configuration in any other .groovy file and wrap it with some identifier like so:

myConfigName {
    // normal config here
}

and then load it in the doWithSpring closure in the MyWrapperPlugin.groovy class via some slurper. However if i understand this correctly, this will only put the configuration in a grails.plugin.mywrapper namespace.

I could not find any example which tries to achieve the same thing (setting the configuraiton of a plugin inside another plugin) up to now.

Any examples/hints are appreciated, thanks!

You can use the Grails Platform Core that

provides functionality for plugins to use to achieve greater integration with each other and with applications

The Configuration API it's what you are looking for. Just add the doWithConfig in your plugin descriptor file (*GrailsPlugin.groovy):

def doWithConfig = { config ->
  application {
    grails.plugins.springsecurity.ldap.active=true
    ...
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM