hellified
hellified

Reputation: 82

Playframework 2.4.x configuration file includes

Playframework:2.4.4 Scala: 2.11 Java: openjdk version "1.8.0_66"

I'm trying to include configuration files in order to make environment specific configurations.

developer.conf:

include "application.conf"

db.default.driver="org.postgresql.Driver"
db.default.url="jdbc:postgresql://localhost/mobile_server"
db.default.username="mobile_user"
db.default.password="password"

liquibase: {
    driver   = "org.postgresql.Driver"
    url      = "jdbc:postgresql://localhost/mobile_server"
    user     = "mobile_user"
    password = "password"
}

The issue is, it seems as if after going to the included "application.conf" file, the parser never returns to parse the rest of the 'main' file. So the database properties, for instance, are never set.

Has anyone else experienced this?

Upvotes: 0

Views: 56

Answers (2)

hellified
hellified

Reputation: 82

So it seems my issue was forking during testing, to speed up testing times. When you do that it drops your "-D" options. In order to keep them you need to do something like this in your build.sbt file:

javaOptions in Test += "-Dconfig.resource=developer.conf"

which is described in the sbt documentation under "Forked JVM options":

http://www.scala-sbt.org/0.13.5/docs/Detailed-Topics/Forking.html

It essentially instructs sbt to pass the desired option along to all forked JVM processes.

Upvotes: 1

Zoltán
Zoltán

Reputation: 22146

You have to explicitly tell activator to use your developer.conf file. Start activator like this:

activator -Dconfig.file=conf/developer.conf

What you are probably experiencing is not that it "only reads the include statement", but that activator just loads your default configuration file, which is application.conf, unless specified otherwise.

Upvotes: 0

Related Questions