Access project version within elixir application

后端 未结 6 2109
故里飘歌
故里飘歌 2021-02-12 07:52

I have an elixir project with a defined version. How can I access this from within the running application.

in mix.exs

  def project do
    [app: :my_app         


        
6条回答
  •  说谎
    说谎 (楼主)
    2021-02-12 08:41

    Mix.Project itself provides access to all project keywords defined in mix.exs using its config/0 (api doc) function. For concise access it might be wrapped into a function:

    @version Mix.Project.config[:version]
    def version(), do: @version
    

提交回复
热议问题