Teena George
Teena George

Reputation: 198

include environment specific file in playframework

Is it possible to achieve this in an application.conf file?

env = ${?ENV}".auth.conf" 
include env

The 'include' statement does not accept env. As far as I know, I can only pass a string to include, like:

include "dev.auth.conf"

Is there a way to specify a variable to the 'include' statement?

Upvotes: 1

Views: 31

Answers (1)

Paul Draper
Paul Draper

Reputation: 83393

No, that is not possible.

From the HOCON spec

Value concatenation is NOT performed on the "argument" to include or url() etc. The argument must be a single quoted string. No substitutions are allowed, and the argument may not be an unquoted string or any other kind of value.

The hypothetical feature is complicated.

a = ${b}
b = 1

resolves to a = 1. In that pattern,

include ${b}.conf
b = 1

should include 1.conf.

But what if b = 1 is defined in another include? Is

include filehavingb.conf
include ${b}.conf

different than

include ${b}.conf
include filehavingb.conf

And other complications.

Anyway, this is discussed at https://github.com/typesafehub/config/issues/122

The easiest way to achieve a similar result currently is using -Dconfig.file

Upvotes: 1

Related Questions