7

I'm working on a Play library that's designed to plug into both the build process and the application code. I want the library to be centrally configured from the application's application.conf, and both the build-time and run-time parts need to access that configuration. At run-time, this is no problem; I just define a reference.conf with any defaults and use ConfigFactory.load, as usual.

However, I'm not sure what's best for build-time. I'm using the following in an SBT task:

import com.typesafe.config.ConfigFactory
val baseDir = baseDirectory.value
val config = ConfigFactory.parseFile(baseDir / "conf/application.conf")

, because ConfigFactory.load doesn't seem to work at build-time. But this strikes me as poor form, because it bypasses the normal logic of load. Is there a preferred way of doing this?

acjay
  • 34,571
  • 6
  • 57
  • 100
  • Seems similar here: http://stackoverflow.com/questions/14430088/play-framework-2-1-use-play-api-configuration-in-build-scala – Barry Feb 24 '15 at 21:53
  • 1
    @Barry Thanks for the link, I hadn't seen that. Although, as you can see, that's more or less what I'm currently doing now. The only thing that concerns me is that this doesn't fully implement the logic of `load`, with its chain of fall-backs, and whatever else it might do. I suppose that might be just how it is, though. – acjay Feb 25 '15 at 04:13

0 Answers0