0
votes

I have trouble understanding the mechanism of merging resource files in Typesafe Config.

According to the Typesafe config documentation:

The convenience method ConfigFactory.load() loads the following (first-listed are higher priority):

  • system properties
  • application.conf (all resources on classpath with this name)
  • application.json (all resources on classpath with this name)
  • application.properties (all resources on classpath with this name)
  • reference.conf (all resources on classpath with this name)

Suppose I have two modules: a and b, and module a depends on module b.

lazy val a = (project in file("a"))
  ...
  .dependsOn(b % "compile->compile;test->test")

If both modules have a resource file reference.conf, how they will get merged?

Is it appending? Is so, how does it resolve conflicts?

1

1 Answers

0
votes

I believe they are overriding in reverse classpath order (could not find the docs to confirm this).

classpath: a.jar;b.jar;

-> 

b reference.conf will be loaded first and then overridden by a reference.conf

This makes it consistent with how .properties files are read, the first in the classpath will be used.

I think it is a good idea to be explicit about your overrides however, either programmatically or by using reference.conf and application.conf as intended.