简体   繁体   中英

Define dependant application on compile time on mix.ex

In a module I am calling HTTPoison.start() (related question Use HTTPoison to initialize a module attribute )

But I would like to configure it in mix.ex , I have read the mix ex documentation and added it to extra_applications: [:httpoison] but didnt work, also tried with applications and included_applications , what am I doing wrong?

Edit.

defmodule TestDep.MixProject do
  use Mix.Project

  def project do
    [
      app: :testdep,
      version: "0.1.0",
      elixir: "~> 1.6",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger]
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      {:httpoison, "~> 1.0"}
      # {:dep_from_hexpm, "~> 0.3.0"},
      # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
    ]
  end
end

defmodule TestDep do
  @moduledoc """
  Documentation for TestDep.
  """

  #HTTPoison.start()
  HTTPoison.get! "www.google.es"
end

Until someone brings a possible solution I will answer a reply from elixir forums:

Applications listed in extra_applications are still started at start up time, not at compile-time. If you need to use HTTPoison at compile-time, you need to start it at compile time manually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM