Question

In a Scala Play2 application I want to define indivdual settings for different environments. My approach is to use different .conf files and start with -Dconfig.file=... .

Things work when calling

play -Dconfig.file=conf/application.conf

or

play -Dconfig.file=conf/test.conf

but when calling

activator -Dconfig.file=conf/application.conf ui

I get a

java.lang.ClassNotFoundException: Global$

Am I wrong assuming that -Dconfig.file would work the same for Activator? What's the right way to get what I want with Activator?

application.conf:

...

application.global=Global

...

test.conf:

...

application.global=GlobalForTest

...

Global.scala:

object Global extends GlobalSettings {

  override def onStart(app: Application) {
    Logger.info("Application has started")
    AppContext.databaseDetails = "default database details"
  }

}

GlobalForTest.scala:

object GlobalForTest extends GlobalSettings {

  override def onStart(app: Application) {
    Logger.info("Application has started in test mode")
    AppContext.databaseDetails = "test database details"
  }

}
Was it helpful?

Solution

Can you open a bug on activator? It looks like config.file is not being passed down to our forked sbt processes. We need to provide some mechanism for you to control what sys variables are passed down to forked sbt, or add/control them somehow. Right now, this is a UI limitation.

However, ./activator test and ./activator run should operate in the same fashion as play.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top