Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration: Environments block not merged from plugins #9376

Closed
kdickerson opened this issue Oct 26, 2015 · 11 comments
Closed

Configuration: Environments block not merged from plugins #9376

kdickerson opened this issue Oct 26, 2015 · 11 comments

Comments

@kdickerson
Copy link

Not sure if this is a bug or just undocumented behavior (undocumented as far as I could find at least).

We have several applications with common configuration that we'd like to modularize into a plugin. We have this all working in Grails 2.x and we're trying to migrate to 3.x.

We'd like to make the configurations, per environment, once in the plugin and then have them available in each application that includes the plugin (done as an inline plugin if it makes a difference).

In my testing, the plugin's application.yml is merged with the application's application.yml, but the environments block is ignored.

It would be very helpful to us if the environments block was not ignored, but if that's intentional could it be added to the documentation? (And, if it's intentional, any thoughts on a good workaround for what we're trying to do?)

Grails: 3.0.8 & 3.0.9
Java: 1.7
OS: Win 7 64-bit

@kdickerson
Copy link
Author

I've done some experimentation to better understand the actual behavior rather than the documented behavior.

My experiments involve an application that uses an inline plugin. I will use the following shorthand:

  • application-application.yml to mean the application's application.yml file
  • plugin-application.yml to mean the plugin's application.yml file
  • plugin-plugin.yml to mean the plugin's plugin.yml file

In my experimentation this is the behavior I am seeing:

  • Entries within plugin-application.yml are NOT present when the application runs.

  • Entries within plugin-plugin.yml are present when the application runs.

  • If application-application.yml defines the same map entry as the plugin-plugin.yml, they will be merged. EXCEPT:

  • If plugin-plugin.yml contains

    environments:
      development:
        something: 'value'
    

    The config value 'something' will NOT be present in the application.

  • Anchors in plugin-plugin.yml cannot be referenced in application-application.yml

My experience is in contradiction with the documentation on upgrading plugins which states that a plugin's application.yml will be merged with the application's application.yml: https://grails.github.io/grails-doc/latest/guide/upgrading.html#upgradingPlugins Step 5. (The second Step 5 since there are 2.)

However, aside from the environments, it does match a statement by @graemerocher in this Google Groups post: https://groups.google.com/forum/#!topic/grails-dev-discuss/UrMirr517FU

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

TL;DR

  1. The documentation on plugin configuration needs to be updated to match reality.
  2. My issue title still stands: Environment blocks defined in plugin.yml do not become part of the application's configuration object. Which, if intentional, should be added to the documentation (and any advice on using common per-environment configurations to avoid repeating ourselves across applications?).

@jeffscottbrown
Copy link
Member

Looks possibly related but not the same thing as #9189

@kdickerson
Copy link
Author

It also seems to be the case that a dataSource block (outside of the environments block) within plugin.yml will not propagate into the application's configuration.

@ctoestreich
Copy link
Contributor

I think there are 2 possible solutions here.

  1. Support environment block merging from the plugin.yml files
  2. Support plugin-[environment].yml files

Either will work for us but this is a lost feature from 2.x where plugin configs (enviornment specific) could be merged manually via grails.config.locations from consuming projects.

👍 :shipit:

@ctoestreich
Copy link
Contributor

I submitted pull request with with option 2 above.

#9471

@ctoestreich
Copy link
Contributor

I have created a new pull request #9491 to allow for multiple plugin environment configs via environment: blocks in the plugin.yml

@graemerocher
Copy link
Member

Thanks for the pull request!

@graemerocher graemerocher added this to the grails-3.1.0.RC1 milestone Dec 18, 2015
@graemerocher
Copy link
Member

m

@bdbogjoe
Copy link
Contributor

if i use plugin.groovy it will be merged as well like plugin.yml ?

@bdbogjoe
Copy link
Contributor

@appienvanveen
Copy link

appienvanveen commented Jul 22, 2016

Hi,

can you explain me why the dataSource and hibernate properties are ignoed in a plugin.yml?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants