How to configure a grails plugin from another grails plugin

人走茶凉 提交于 2019-12-23 12:53:30

问题


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!


回答1:


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
    ...
  }
}


来源:https://stackoverflow.com/questions/13128381/how-to-configure-a-grails-plugin-from-another-grails-plugin

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