How to configure Grails plugin from another Grails plugin

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

This means that it should contain:

  • Domain Classes for User / Roles
  • Spring security configuration (mapping these domain classes, some default URL role configuration)

My problem is that I cannot configure the configuration inside my plugin. I am confused by the examples that I have found so far: sometimes I read that the configuration should just go to "Config.groovy", however grails docs state that this file is not part of the plugin at the end. Some examples say that you should put the configuration in any other .groovy file and wrap it with some sort of identifier:

myConfigName { // normal config here } 

and then load it into doWithSpring closure in the MyWrapperPlugin.groovy class via some kind of slurper. However, if I understand this correctly, it will only lead to configuration in the grails.plugin.mywrapper namespace.

I could not find a single example that is trying to achieve the same (configuring the plugin configuration inside another plugin) so far.

Any examples / tips are appreciated, thanks!

+4
source share
1 answer

You can use Grails Platform Core which

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

The configuration API is what you are looking for. Just add doWithConfig to your plugin descriptor file (* GrailsPlugin.groovy):

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

Source: https://habr.com/ru/post/1442840/


All Articles