defmodule SourcedPostgres.MixProject do use Mix.Project @version "0.1.0" @source_url "https://gitlab.com/dimakula/sourced" 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 LICENSE) ] end defp docs do [ main: "readme", extras: ["README.md"], source_url: @source_url, # See core/mix.exs: the default pattern assumes the mix project is the # repository root, which would drop the `postgres/` prefix from every link. source_url_pattern: "#{@source_url}/-/blob/#{@version}/postgres/%{path}#L%{line}" ] end # The adapter contract lives in core and is compiled only in :test, so it is # not part of the :sourced dependency build. Compile it into this app instead. # Mix requires external elixirc_paths entries to be absolute. defp elixirc_paths(:test), do: ["lib", "test/support", Path.expand("../core/contract", __DIR__)] defp elixirc_paths(_), do: ["lib"] # Run "mix help deps" to learn about dependencies. defp deps do [ {:sourced, sourced_dep()}, {: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 # Hex excludes path dependencies from a package rather than resolving them to # their version requirement, so `mix hex.build` fails outright on the in-repo # path. Set SOURCED_HEX_BUILD to swap in the published requirement when # building or publishing the tarball; everything else uses the sibling # checkout, so a change in core/ is picked up without a release. defp sourced_dep do if System.get_env("SOURCED_HEX_BUILD") do "~> #{@version}" else [path: "../core", override: true] end end end