Current section

Files

Jump to
Raw

mix.exs

defmodule TestServer.MixProject do
  use Mix.Project

  @source_url "https://github.com/danschultzer/test_server"
  @version "1.0.0"

  def project do
    [
      app: :test_server,
      version: @version,
      elixir: "~> 1.15",
      elixirc_paths: elixirc_paths(Mix.env()),
      start_permanent: Mix.env() == :prod,
      deps: deps(),

      # Hex
      description: "Mock third-party services in ExUnit",
      package: package(),

      # Docs
      name: "TestServer",
      docs: docs()
    ]
  end

  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  def application do
    [
      extra_applications: extra_applications(Mix.env()),
      mod: {TestServer.Application, []}
    ]
  end

  defp extra_applications(:test), do: extra_applications(:prod) ++ [:tftp]
  defp extra_applications(_), do: [:logger, :crypto, :public_key, :ssl, :ssh, :inets]

  defp deps do
    [
      {:plug, "~> 1.18"},
      {:x509, "~> 0.6"},

      # Optional web servers
      {:bandit, "~> 1.7", optional: true},
      {:plug_cowboy, "~> 2.9", optional: true},

      # Development and test
      {:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
      {:credo, ">= 0.0.0", only: [:dev, :test]},
      {:websockex, "~> 0.5.1", only: [:test]},
      {:finch, ">= 0.0.0", only: [:test]},
      {:gen_smtp, "~> 1.3", only: :test},
      {:sshkit, "~> 0.3", only: :test},
      {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}
    ]
  end

  defp package do
    [
      maintainers: ["Dan Schultzer"],
      licenses: ["MIT"],
      links: %{
        "GitHub" => @source_url,
        "Sponsor" => "https://github.com/sponsors/danschultzer"
      },
      files: ~w(CHANGELOG.md lib LICENSE mix.exs README.md)
    ]
  end

  defp docs do
    [
      source_ref: "v#{@version}",
      main: "TestServer",
      canonical: "https://test-server.hexdocs.pm",
      source_url: @source_url,
      extras: [
        "CHANGELOG.md": [filename: "CHANGELOG"]
      ],
      skip_undefined_reference_warnings_on: [
        "CHANGELOG.md"
      ],
      groups_for_modules: [
        Protocols: [
          TestServer.HTTP,
          TestServer.TCP,
          TestServer.UDP,
          TestServer.SSH
        ],
        "HTTP Servers": [
          TestServer.HTTP.Server,
          TestServer.HTTP.Server.Httpd,
          TestServer.HTTP.Server.Bandit,
          TestServer.HTTP.Server.Plug.Cowboy
        ]
      ]
    ]
  end
end