mkorszun
mkorszun

Reputation: 4571

How to deal with multiple application config files in elixir umbrella application

I have an elixir umbrella application (A) which has multiple applications underneath. One of them (B) is defined is separate repository and contains its own config (config/config.exs) file, mostly with default values.

When adding application B to A and starting umbrella application, configuration for application B is not loaded. It looks like I need to explicitly include all configuration params for B in A config.

I would expect that config for application B will be still available in application A and I would only have to override some specific values.

Could anyone explain to me how I can achieve it without specifying all config params again in main application (A) config file?

Upvotes: 1

Views: 1910

Answers (1)

Mike Buhot
Mike Buhot

Reputation: 4885

An umbrella application generated with mix new --umbrella should automatically include the configs of all applications.

In your_project/apps/app_a/mix.exs it should be configured to read the config from the umbrella root:

 build_path: "../../_build",
 config_path: "../../config/config.exs",
 deps_path: "../../deps",
 lockfile: "../../mix.lock",

And in your_project/config/config.exs, it should include all apps config:

use Mix.Config

# By default, the umbrella project as well as each child
# application will require this configuration file, ensuring
# they all use the same configuration. While one could
# configure all applications here, we prefer to delegate
# back to each application for organization purposes.
import_config "../apps/*/config/config.exs"

Upvotes: 4

Related Questions