Packages

A PostgreSQL event store adapter for Sourced, built on Postgrex.

Current section

Files

Jump to
Raw

mix.exs

defmodule SourcedPostgres.MixProject do
  use Mix.Project

  @version "0.3.0"
  @source_url "https://gitlab.com/dimakula/sourced-postgres"

  def project do
    [
      app: :sourced_postgres,
      version: @version,
      elixir: "~> 1.15",
      start_permanent: Mix.env() == :prod,
      elixirc_paths: elixirc_paths(Mix.env()),
      description: description(),
      package: package(),
      docs: docs(),
      source_url: @source_url,
      dialyzer: [
        # :ex_unit because this app compiles core's contract suite into its own
        # :test build (see elixirc_paths below), so Dialyzer sees the same
        # ExUnit.CaseTemplate calls that core does.
        plt_add_apps: [:mix, :ex_unit],
        # See core/mix.exs: keeps both PLTs where GitLab's cache can reach them.
        plt_core_path: "plts",
        plt_local_path: "plts"
      ],
      deps: deps()
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger],
      mod: {Sourced.EventStore.Postgres.Application, []}
    ]
  end

  defp description do
    "A PostgreSQL event store adapter for Sourced, built on Postgrex."
  end

  defp package do
    [
      licenses: ["Apache-2.0"],
      links: %{"GitLab" => @source_url},
      files: ~w(lib mix.exs .formatter.exs README.md CHANGELOG.md LICENSE)
    ]
  end

  defp docs do
    [
      main: "readme",
      extras: ["README.md", "CHANGELOG.md"],
      source_url: @source_url,
      # Pinned to the release tag so published docs keep pointing at the code
      # they were built from.
      source_url_pattern: "#{@source_url}/-/blob/#{@version}/%{path}#L%{line}"
    ]
  end

  # The adapter contract suite ships inside the :sourced package but is compiled
  # only in :test there, so it is not part of the dependency's build. Compile it
  # into this app instead, which pins it to the :sourced version in the lock.
  # Kept relative: Mix accepts elixirc_paths entries that are relative to the
  # project or absolute and outside it, and this one lives under the project.
  defp elixirc_paths(:test),
    do: ["lib", "test/support", "deps/sourced/contract"]

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

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      {:sourced, "~> 0.2"},
      {:postgrex, "~> 0.22"},
      {:ecto, "~> 3.10"},
      {:ecto_sql, "~> 3.10"},

      # Dev/test dependencies
      {:credo, "~> 1.7", only: [:dev, :test], runtime: false},
      {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
      {:ex_doc, "~> 0.34", only: :dev, runtime: false}
    ]
  end
end