Grails 3 Plugin Config Files

瀏覽次數:338 次
跳到第一則未讀訊息

Aaron

未讀,
2015年10月29日 下午6:24:142015/10/29
收件者:Grails Dev Discuss
We have a couple of projects that shared an inline plugin in Grails 2. I've switched to using the Gradle sub-project (which is nice) but I'm a little unsure of how the configuration is supposed to work.

For example, we had a plugin called "common" (original, I know) that had some common configuration in CommonConfig.groovy. Now it seems like application.groovy is where the config should go, but I think that will be overridden by the application.groovy in my application (or it seems to be).

If I want to have some base configuration in a plugin that can be used by the application, what's the best way to do that in Grails 3?

Also, it's not clear what are the rules if you have both an application.yml and an application.groovy, which one takes precendence? I assume they are sort of merged together (hopefully the groovy one would override the YML file). The docs don't really seem to discuss it.

Thanks,
-Aaron

Sergio Michels

未讀,
2015年10月29日 晚上8:11:362015/10/29
收件者:grails-de...@googlegroups.com
I was just watching Grails 3.x update and Graeme said that if you have both groovy and yml application files they get merged.

Not sure yet the order of the files in the merge.  

--
Sérgio Michels

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/849b05a0-064c-4da0-a45a-932e8bd8b7d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sergio Michels

未讀,
2015年10月29日 晚上8:18:512015/10/29
收件者:grails-de...@googlegroups.com
And I'm interesting in this topic too, currently working on the Melody plugin migration and just left the original code

static ConfigObject getGrailsMelodyConfig(GrailsApplication application) {
  def config = application.config
  GroovyClassLoader classLoader = new GroovyClassLoader(application.getClassLoader())
  try {
  config.merge(new ConfigSlurper(Environment.current.name().toLowerCase()).parse(classLoader.loadClass('GrailsMelodyConfig')))
  } catch (Exception e) {
  // ignored, use defaults
  }
  return config
}

--
Sérgio Michels

Graeme Rocher

未讀,
2015年10月31日 上午8:17:412015/10/31
收件者:grails-de...@googlegroups.com

In 3.x if you define a plugin.yml file the configure in this file becomes the defaults and is available to the application.

The application can also override the config but still access the default values using the "grails.plugin.foo" prefix where "foo" is the plugin name 

Aaron

未讀,
2015年11月5日 上午11:00:302015/11/5
收件者:Grails Dev Discuss
Cool, that works for plugin.yml but does not seem to care or know about a plugin.groovy. Would be nice if it was consistent with the way application.groovy and application.yml work.

I assume the response to that statement might be "contributions are always welcome" ;)

Thanks,
Aaron

--
Sérgio Michels


--
Sérgio Michels

To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-discuss+unsub...@googlegroups.com.

Christian Oestreich

未讀,
2015年12月8日 下午4:02:252015/12/8
收件者:Grails Dev Discuss
@Graeme Does the environment setting get interrogated in this scheme and also work for plugin-development.yml (i.e. plugin-[environment].yml?

Christian Oestreich

未讀,
2015年12月8日 下午4:35:212015/12/8
收件者:Grails Dev Discuss
I was hoping that the enviroments property would work in the plugin.yml but I have confirmed that it is not and will either show the base property 'plugin.yml' or the spring value ${plugin.name} when using the following plugin.yml file in a plugin.

plugin:
name: plugin.yml

environments:
dev:
plugin:
name: env-dev-plugin.yml
prod:
plugin:
name: env-prod-plugin.yml
development:
plugin:
name: env-development-plugin.yml
production:
plugin:
name: prod-development-plugin.yml
回覆所有人
回覆作者
轉寄
0 則新訊息