Env-specific deps

Posted . Visible to the public.

I found myself in the situation where I wanted to have a dependency only compiled in my dev env. You can do this as follows: -

  def project do
    [ app: :my_proj,
      version: "0.0.1",
      elixir: "~> 0.12.3",
      env: [
        dev:  [deps: dev_deps],
        test: [deps: deps],
        prod: [deps: deps]
      ]
    ]
  end

  defp deps do
    []
  end

  defp dev_deps do
    [
      { :ex_doc, github: "elixir-lang/ex_doc" }
    ] ++ deps
  end

If anyone knows of a cleaner way to share common deps, please to share. :)

Alan Gardner
Posted by Alan Gardner to elixir tips (2014-02-10 10:11)