Current section

Files

Jump to
Raw

mix.exs

defmodule Calendrical.MixProject do
  use Mix.Project

  @version "2.0.0"

  def project do
    [
      app: :calendrical,
      version: @version,
      elixir: "~> 1.17",
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      elixirc_paths: elixirc_paths(Mix.env()),
      name: "Calendrical",
      description: description(),
      package: package(),
      docs: docs(),
      dialyzer: [
        plt_add_apps: ~w(inets json mix calendar_interval)a,
        ignore_warnings: ".dialyzer_ignore.exs",
        flags: [
          :error_handling,
          :unknown,
          :underspecs,
          :extra_return,
          :missing_return
        ]
      ],
      test_coverage: [
        summary: [threshold: 90],
        # Test-support calendars, generators and fixtures compiled from
        # test/support are not part of the library surface and would
        # distort the coverage total.
        ignore_modules: [
          Calendrical.BasicWeek,
          Calendrical.CSCO,
          Calendrical.Reform.Sweden,
          Calendrical.Reform.Japan,
          Calendrical.Reform.England,
          Calendrical.Fiscal.AU,
          Calendrical.Fiscal.UK,
          Calendrical.Fiscal.US,
          Calendrical.Helper,
          Calendrical.IL,
          Calendrical.Persian.TestData,
          Calendrical.Russia,
          Calendrical.SequentialWeeks,
          ~r/^Calendrical\.Test\./,
          ~r/^Calendrical\.Range(\.|$)/,
          ~r/\.DateGenerator$/
        ]
      ],
      compilers: Mix.compilers()
    ]
  end

  defp description do
    """
    Localized month- and week-based calendars and calendar functions
    based upon CLDR data via Localize.
    """
  end

  def package do
    [
      maintainers: ["Kip Cole"],
      licenses: ["Apache-2.0", "Unicode-3.0"],
      links: links(),
      files: [
        "lib",
        "priv",
        "guides",
        "mix.exs",
        "README*",
        "usage-rules.md",
        "CHANGELOG*",
        "LICENSE*"
      ]
    ]
  end

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

  def docs do
    [
      source_ref: "v#{@version}",
      main: "readme",
      logo: "logo.png",
      extras:
        [
          "README.md",
          "LICENSE.md",
          "LICENSE-UNICODE.md",
          "CHANGELOG.md"
        ] ++ Path.wildcard("guides/*.md"),
      formatters: ["html", "markdown"],
      groups_for_modules: groups_for_modules(),
      groups_for_extras: groups_for_extras(),
      skip_undefined_reference_warnings_on:
        [
          "CHANGELOG.md"
        ] ++ Path.wildcard("guides/*.md")
    ]
  end

  def groups_for_modules do
    [
      "Gregorian Month-based Calendars":
        ~r/^Calendrical\.(Gregorian|Buddhist|Japanese|Roc|Indian)$/,
      "Gregorian Week-based Calendars": ~r/^Calendrical\.(ISOWeek|NRF)$/,
      "Julian Calendars": ~r/^Calendrical\.Julian(\.(Jan1|March1|March25|Sept1|Dec25))?$/,
      "Lunisolar Calendars":
        ~r/^Calendrical\.(Chinese|Korean|Vietnamese|LunarJapanese|Hebrew|Lunisolar)$/,
      "Ethiopic Calendars": ~r/^Calendrical\.Ethiopic(\.AmeteAlem)?$/,
      "Islamic Calendars":
        ~r/^Calendrical\.Islamic\.(Civil|Tbla|Observational|Rgsa|UmmAlQura(\.Astronomical|\.ReferenceData)?)$/,
      "Ecclesiastical Calendars": ~r/^Calendrical\.Ecclesiastical$/,
      "Other Calendars": ~r/^Calendrical\.(Persian|Composite|Coptic)$/,
      "Reform Calendars": ~r/^Calendrical\.Reform(\.(Sweden(\.Transitional)?|Japan|England))?$/,
      "Fiscal-year Calendars": ~r/^Calendrical\.FiscalYear$/,
      Makers: [
        Calendrical.Calendar,
        Calendrical.Calendar.Shifted,
        Calendrical.Calendar.Weeks,
        Calendrical.Calendar.Lunisolar,
        Calendrical.Composite
      ],
      "Derived API": [
        Calendrical.Info,
        Calendrical.Month,
        Calendrical.Week,
        Calendrical.Period,
        Calendrical.Era,
        Calendrical.Shift
      ],
      Behaviours: [Calendrical.Formatter],
      Parsing: [
        Calendrical.Date,
        Calendrical.DateTime,
        Calendrical.Time,
        Calendrical.TimeZone
      ],
      Formatting: ~r/^Calendrical\.Format$/,
      Intervals: ~r/^Calendrical\.Interval$/,
      "K-day Calculations": ~r/^Calendrical\.Kday$/,
      Preference: ~r/^Calendrical\.Preference$/,
      Eras: ~r/^Calendrical\.Era/,
      Exceptions: ~r/^Calendrical\..*Error$/
    ]
  end

  defp groups_for_extras do
    [
      Guides: [
        "guides/calendar_summary.md",
        "guides/calendar_behaviour.md",
        "guides/composite_calendars.md",
        "guides/parsing.md",
        "guides/migration.md"
      ]
    ]
  end

  def application do
    [
      mod: {
        Calendrical.Application,
        [
          strategy: :one_for_one,
          name: Calendrical.Supervisor
        ]
      },
      extra_applications: [:logger]
    ]
  end

  defp deps do
    [
      {:localize, "~> 1.4"},
      {:astro, "~> 2.8"},
      {:tz_world, "~> 2.3", optional: true},
      {:tz, "~> 0.26", optional: true},
      {:gettext, "~> 1.0"},
      {:calendar_interval, "~> 0.2", optional: true},
      {:ex_doc, "~> 0.38", only: [:dev, :release], runtime: false},
      {:dialyxir, "~> 1.0", optional: true, only: [:dev, :test], runtime: false},
      {:credo, "~> 1.7", optional: true, only: [:dev, :test], runtime: false},
      {:stream_data, "~> 1.0", only: :test}
    ] ++ maybe_json_polyfill()
  end

  defp maybe_json_polyfill do
    if Code.ensure_loaded?(:json) do
      []
    else
      [{:json_polyfill, "~> 0.2 or ~> 1.0", only: [:dev, :test]}]
    end
  end

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