Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge conf files at the end of loading. #211

Closed
C-h-e-r-r-y opened this issue Nov 10, 2014 · 1 comment
Closed

Merge conf files at the end of loading. #211

C-h-e-r-r-y opened this issue Nov 10, 2014 · 1 comment

Comments

@C-h-e-r-r-y
Copy link

I have two files - reference.conf and application.conf

application.conf

app {
    port = 5000
}

reference.conf

akka {
    cluster {
        seed-nodes = ["akka.tcp://sysName@localhost:"${app.port}]
    }
}

The goal with example above is simple - to extract only necessary properties into applicaiton.conf and reuse reference.conf in different applications without duplicating properties in it. It looks like pom files in maven - parent pom contains everything, but child only defines necessary properties.

When ConfigFactory.load() is invoked it loads reference.conf, then loads application.conf, merges they together and override properties reference from application. With that algorithm load function fails, because reference.conf do not contain app.port property which is defined in application.conf. Is it expected behavior? May be a correct algorithm will be to merge plain text files application.conf and reference.conf and then resolve properties in it?

Also can resolve these properties just add include "application". But first in that case module with reference depends on unexisted file and second - what if there are several files, which named differently that application, but need to reuse reference.conf too?

So in total: resolve a bug or add feature to merge conf files at the end (it can be as default behavior or as pass a argument to ConfigFactory.load())

@havocp
Copy link
Collaborator

havocp commented Nov 10, 2014

#167 has discussion of this and some suggestions. One option is to have multiple application.conf or reference.conf. Or have something.conf which all your application.conf pull in.

This policy decision in ConfigFactory.load is only the thinnest of surface convenience layers, so worst case you can copy a short method out of ConfigFactory.java and tweak it as desired.

Changing how it works by default isn't really feasible due to back compat.

@havocp havocp closed this as completed Nov 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants