Search code examples
elixirelixir-mix

How do I configure mix.exs to make umbrella project apps share the same version?


I want to define the version in the root mix.exs. The project in apps can read this version. Can it be configured like this?


Solution

  • root mix.exs:

    defmodule MyCoolUmbrellaApp.Mixfile do
      use Mix.Project
    
      def project do
        [app: :my_cool_umbrella_app,
         version: "1.0",
         apps_path: "apps",
         build_embedded: Mix.env == :prod,
         start_permanent: Mix.env == :prod,
         deps: deps()]
      end
    
      defp deps do
        [
    
       ]
      end
    end
    

    code in one of the apps in the umbrella:

    defmodule SomeApp.SomeModule do
    
      def some_function() do
        project = Mix.Project.get.project
        app     = project[:app]
        version = project[:version]