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

Support plugin.yml and plugin-[environment].yml in grails plugins #9471

Closed
wants to merge 1 commit into from
Closed

Support plugin.yml and plugin-[environment].yml in grails plugins #9471

wants to merge 1 commit into from

Conversation

ctoestreich
Copy link
Contributor

This feature will attempt to load an environment and general plugin config such as:

plugin-[environment].yml
plugin.xml

The order at which they are processed as resources should be environment first then generic so that environment wins out over general.

@graemerocher
Copy link
Member

I'm not sure that loading more files is the solution and would prefer option 1) (i.e. allowing environment blocks inside plugin.yml). This will only slow down startup time more.

@ctoestreich
Copy link
Contributor Author

I didn't see a place to use as an example on how to parse and merge the environment maps as the plugin configs were treated a bit differently so I went with option 2.

In the grails 2.x world we chose multiple configs as it kept them clean and did something like this at the top level project to consume plugins environment configs with a file dropped on the classpath of tomcat "enviornment.properties" able to take precedent over all other configs for production passwords etc.

grails.config.locations = ["classpath:bsb-core-domain.properties",
                           "classpath:bsb-core-domain-${Environment.current.name}.properties",
                           "classpath:bsb-core-web.properties",
                           "classpath:bsb-core-web-${Environment.current.name}.properties",
                           "classpath:bsb-web.properties",
                           "classpath:bsb-web-${Environment.current.name}.properties",
                           "classpath:environment.properties"]

@ctoestreich
Copy link
Contributor Author

As it stands today we will have to move all the environment config stuff to the top projects and duplicate it across the many top level apps that consume our plugins. Not impossible, but a problem to keep in sync and a bunch of duplication.

@ctoestreich
Copy link
Contributor Author

I did confirm that at java -jar runtime you can put an arbitrary config into your plugin and use it in an application as the config below. Both the web and plugin contain an arbitrary properties or yml file in the conf directory.

foo-web --> grails-app/conf/environment.properties
foo-plugin --> grails-app/conf/plugin-development.yml
foo-web <-- foo-plugin

The following will use the environment properties from the web app as it is the last in the chain:
java -jar foo-web-0.1.jar --spring.config.location=classpath:plugin-development.yml,classpath:environment.properties

The following will use the plugin-development.yml from the plugin as it is the last in the chain:
java -jar foo-web-0.1.jar --spring.config.location=classpath:environment.properties,classpath:plugin-development.yml

I, however, can not get a scenario using bootRun to recognize the --spring.config.location=classpath:plugin-development.yml

@graemerocher
Copy link
Member

@ctoestreich
Copy link
Contributor Author

Closing in favor of merging environemnts

@ctoestreich
Copy link
Contributor Author

New pull request 9491

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

Successfully merging this pull request may close these issues.

2 participants