Grails 3 Plugin Config Files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails 3 Plugin Config Files

longwa
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

--
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 [hidden email].
To post to this group, send email to [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 3 Plugin Config Files

sergiomichels
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

On Thu, Oct 29, 2015 at 8:24 PM, Aaron <[hidden email]> wrote:
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

--
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 [hidden email].
To post to this group, send email to [hidden email].
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.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAHTf1NUX73KeegFFHTXq669KeZCRN%2BE%2BU%3D1-FyRQYNRKqFG3GQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 3 Plugin Config Files

sergiomichels
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

On Thu, Oct 29, 2015 at 10:11 PM, Sergio Michels <[hidden email]> wrote:
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

On Thu, Oct 29, 2015 at 8:24 PM, Aaron <[hidden email]> wrote:
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

--
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 [hidden email].
To post to this group, send email to [hidden email].
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.


--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAHTf1NUGvGbDHwtn-Vp2Be1cYhM3UFkhj3yKguWhoZpSTObARw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 3 Plugin Config Files

Graeme Rocher-2

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 

On 30 Oct 2015, at 01:18, Sergio Michels <[hidden email]> wrote:

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

On Thu, Oct 29, 2015 at 10:11 PM, Sergio Michels <[hidden email]> wrote:
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

On Thu, Oct 29, 2015 at 8:24 PM, Aaron <[hidden email]> wrote:
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

--
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 [hidden email].
To post to this group, send email to [hidden email].
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.


--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/CAHTf1NUGvGbDHwtn-Vp2Be1cYhM3UFkhj3yKguWhoZpSTObARw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/38446487-3BE9-4A97-8CA5-7981247A89D8%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 3 Plugin Config Files

longwa
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

On Saturday, October 31, 2015 at 8:17:41 AM UTC-4, Graeme Rocher wrote:

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 

On 30 Oct 2015, at 01:18, Sergio Michels <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="FMXCaT3FDgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">sergiom...@...> wrote:

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(<a href="http://Environment.current.name" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2FEnvironment.current.name\46sa\75D\46sntz\0751\46usg\75AFQjCNHxfUWrhcziZGCdMV5pwDdSngxgOQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2FEnvironment.current.name\46sa\75D\46sntz\0751\46usg\75AFQjCNHxfUWrhcziZGCdMV5pwDdSngxgOQ&#39;;return true;">Environment.current.name().toLowerCase()).parse(classLoader.loadClass('GrailsMelodyConfig')))
  } catch (Exception e) {
  // ignored, use defaults
  }
  return config
}

--
Sérgio Michels

On Thu, Oct 29, 2015 at 10:11 PM, Sergio Michels <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="FMXCaT3FDgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">sergiom...@...> wrote:
I was just watching <a href="http://www.infoq.com/presentations/grails-3-x" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Fwww.infoq.com%2Fpresentations%2Fgrails-3-x\46sa\75D\46sntz\0751\46usg\75AFQjCNFyreDy7Z2PUt4zzfGqcfXaVgl3EQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Fwww.infoq.com%2Fpresentations%2Fgrails-3-x\46sa\75D\46sntz\0751\46usg\75AFQjCNFyreDy7Z2PUt4zzfGqcfXaVgl3EQ&#39;;return true;">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

On Thu, Oct 29, 2015 at 8:24 PM, Aaron <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="FMXCaT3FDgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">lon...@...> wrote:
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

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="FMXCaT3FDgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">grails-dev-discuss+unsubscribe@....
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="FMXCaT3FDgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">grails-de...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/grails-dev-discuss/849b05a0-064c-4da0-a45a-932e8bd8b7d9%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/grails-dev-discuss/849b05a0-064c-4da0-a45a-932e8bd8b7d9%40googlegroups.com?utm_medium\75email\46utm_source\75footer&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/grails-dev-discuss/849b05a0-064c-4da0-a45a-932e8bd8b7d9%40googlegroups.com?utm_medium\75email\46utm_source\75footer&#39;;return true;">https://groups.google.com/d/msgid/grails-dev-discuss/849b05a0-064c-4da0-a45a-932e8bd8b7d9%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.


--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="FMXCaT3FDgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">grails-dev-discuss+unsubscribe@....
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="FMXCaT3FDgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">grails-de...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/grails-dev-discuss/CAHTf1NUGvGbDHwtn-Vp2Be1cYhM3UFkhj3yKguWhoZpSTObARw%40mail.gmail.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/grails-dev-discuss/CAHTf1NUGvGbDHwtn-Vp2Be1cYhM3UFkhj3yKguWhoZpSTObARw%40mail.gmail.com?utm_medium\75email\46utm_source\75footer&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/grails-dev-discuss/CAHTf1NUGvGbDHwtn-Vp2Be1cYhM3UFkhj3yKguWhoZpSTObARw%40mail.gmail.com?utm_medium\75email\46utm_source\75footer&#39;;return true;">https://groups.google.com/d/msgid/grails-dev-discuss/CAHTf1NUGvGbDHwtn-Vp2Be1cYhM3UFkhj3yKguWhoZpSTObARw%40mail.gmail.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/468a3743-0802-4a65-8079-d777d45b97ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 3 Plugin Config Files

Christian Oestreich
@Graeme Does the environment setting get interrogated in this scheme and also work for plugin-development.yml (i.e. plugin-[environment].yml?

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/e7a765e6-14af-4c20-9d3d-f8cf571d7404%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 3 Plugin Config Files

Christian Oestreich
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

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/02e128c0-ebe5-4be0-9d82-b0c840d5ccb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.