Friday, August 9, 2013

Play2 "include" directive override configuration with substitution

Play2 "include" directive override configuration with substitution

I have following conf files in my play2.1.0 application
application.conf
override.dev.conf
override.qa.conf
override.prod.conf
And there is a application.mode property in the application.conf file
which will have either one of dev/qa/prod values.
application.conf also has a line to include env/mode specific conf files
as override. This is what is not working with substitution.
Reason: To have the override properties in the env/mode specific conf files.
Referred: http://www.playframework.com/documentation/2.0/Configuration
If an unquoted include at the start of a key is followed by anything other
than a single quoted string, it is invalid and an error should be
generated.
No substitutions are allowed, and the argument may not be an unquoted
string or any other kind of value.
Tried:
Able to get the substitution done for another property but not for include
like this
my.prop="override."${?application.mode}".conf"
The above outputs to override.dev.conf if application.mode=dev
If I have something like below its not working and i suppose its what is
expected as per the documentation reference.
include 'override.'${?application.mode}'.conf'
Expected the above to include/override props in a file named
override.dev.conf
Question:
Should this be a future enhancement or this is what is expected out of it?
What are the other ways to implement what I wanted?
Any help would be really appreciated.

No comments:

Post a Comment