|
How do I make a config file being read by grails in a plugin.
I am developing an internal plugin for which I want to define default values. I created in that plugin under conf a file named DefaultCrsAuthConfig.groovy, crs- auth being the plugin's name But that file is not being read. I thought any files in conf that end by Config.groovy get read automagically. Thanks in advance Pascal --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
To answer my own question I now merge the config explicitly in the plugin event
system def doWithSpring = { def config = grailsApplication.config def cl = new GroovyClassLoader(getClass().classLoader) def cs = new ConfigSlurper(GrailsUtil.environment) config.merge(cs.parse(cl.loadClass('DefaultCrsAuthConfig'))) } I was hoping there was an implicit way but couldn't find it Thanks Pascal On Monday, December 27, 2010 07:52:10 pm you wrote: > How do I make a config file being read by grails in a plugin. > > I am developing an internal plugin for which I want to define default > values. I created in that plugin under conf a file named > DefaultCrsAuthConfig.groovy, crs- auth being the plugin's name > > But that file is not being read. I thought any files in conf that end by > Config.groovy get read automagically. > > Thanks in advance > > Pascal > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
There isn't an implicit way to do this right now as it has some challenges. The most significant of which is that config needs to be loaded very early, earlier than the plugin subsystem. There is a new explicit mechanism added in 1.3.6 (see docs on externalised config) that users of your plugin could use. That will achieve what you want, but probably not as conventionally as you might like.
With your current approach, be aware that other things may have read the config _before_ you merge in your defaults which makes them ineffectual. The new explicit defaults mechanism doesn't have this problem. I also think you will find that your defaults will override any user values using the approach you have there. On 28/12/2010, at 5:20 PM, Pascal DeMilly <[hidden email]> wrote: > To answer my own question I now merge the config explicitly in the plugin event > system > > def doWithSpring = { > > def config = grailsApplication.config > def cl = new GroovyClassLoader(getClass().classLoader) > def cs = new ConfigSlurper(GrailsUtil.environment) > config.merge(cs.parse(cl.loadClass('DefaultCrsAuthConfig'))) > } > > I was hoping there was an implicit way but couldn't find it > > Thanks > > Pascal > > On Monday, December 27, 2010 07:52:10 pm you wrote: >> How do I make a config file being read by grails in a plugin. >> >> I am developing an internal plugin for which I want to define default >> values. I created in that plugin under conf a file named >> DefaultCrsAuthConfig.groovy, crs- auth being the plugin's name >> >> But that file is not being read. I thought any files in conf that end by >> Config.groovy get read automagically. >> >> Thanks in advance >> >> Pascal >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
