Current section

Files

Jump to
unicode mix.exs
Raw

mix.exs

defmodule Unicode.MixProject do
  use Mix.Project

  @version "2.1.0"

  def project do
    [
      app: :unicode,
      version: @version,
      elixir: "~> 1.17",
      start_permanent: Mix.env() == :prod,
      build_embedded: Mix.env() == :prod,
      deps: deps(),
      docs: docs(),
      name: "Unicode",
      source_url: "https://github.com/elixir-unicode/unicode",
      description: description(),
      package: package(),
      elixirc_paths: elixirc_paths(Mix.env()),
      test_coverage: [
        summary: [threshold: 90],
        ignore_modules: coverage_ignore_modules()
      ],
      dialyzer: [
        plt_add_apps: ~w(mix inets public_key)a,
        ignore_warnings: ".dialyzer_ignore_warnings"
      ]
    ]
  end

  # Modules excluded from `mix test --cover` measurement so the
  # coverage number reflects the runtime library, not build tooling:
  #
  # * `Mix.Tasks.*` — the Unicode data download task, run at build
  #   time, never at library runtime.
  #
  # * Test support modules under `test/support` — test harness code.
  #
  # * `Unicode.DerivedCategory.Printable` — a compile-time data holder whose
  #   only function is evaluated while building a module attribute, so it is
  #   never called at runtime.
  defp coverage_ignore_modules do
    [
      ~r/^Mix\.Tasks\./,
      Unicode.Validation.UTF8.Test.Helpers,
      Unicode.DerivedCategory.Printable
    ]
  end

  defp description do
    """
    Functions to introspect the Unicode character database and
    to provide fast codepoint lookups and guards.
    """
  end

  defp package do
    [
      maintainers: ["Kip Cole"],
      licenses: ["Apache-2.0"],
      logo: "logo.png",
      links: links(),
      files: [
        "lib",
        "data",
        "logo.png",
        "mix.exs",
        "README*",
        "CHANGELOG*",
        "LICENSE*"
      ]
    ]
  end

  def application do
    [
      extra_applications: [:logger, :public_key, :inets, :ssl]
    ]
  end

  defp deps do
    [
      {:benchee, "~> 1.0", only: :dev, optional: true},
      {:ex_doc, "~> 0.24", only: [:dev, :release], runtime: false, optional: true},
      {:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false, optional: true},
      {:credo, "~> 1.7", only: [:dev, :test], runtime: false, optional: true}
    ]
  end

  def links do
    %{
      "GitHub" => "https://github.com/elixir-unicode/unicode",
      "Readme" => "https://github.com/elixir-unicode/unicode/blob/v#{@version}/README.md",
      "Changelog" => "https://github.com/elixir-unicode/unicode/blob/v#{@version}/CHANGELOG.md"
    }
  end

  def docs do
    [
      source_ref: "v#{@version}",
      main: "readme",
      logo: "logo.png",
      extras: [
        "README.md",
        "LICENSE.md",
        "CHANGELOG.md"
      ],
      formatters: ["html", "markdown"],
      skip_undefined_reference_warnings_on: ["changelog", "CHANGELOG.md"]
    ]
  end

  defp elixirc_paths(:test), do: ["lib", "mix", "src", "test"]
  defp elixirc_paths(:dev), do: ["lib", "mix", "src", "bench"]
  defp elixirc_paths(_), do: ["lib", "src"]
end