Packages

Spatial databases and GIS SQL functions. Currently supports PostGIS, Spatialite, MySQL, MariaDB, and Geopackage.

Current section

Files

Jump to
geo_sql mix.exs
Raw

mix.exs

defmodule GeoSQL.Mixfile do
  use Mix.Project

  @source_url "https://github.com/expothecary/geo_sql"
  @version "1.8.2"

  def project do
    [
      app: :geo_sql,
      version: @version,
      elixir: "~> 1.18",
      start_permanent: Mix.env() == :prod,
      name: "GeoSQL",
      deps: deps(),
      package: package(),
      docs: docs(),
      elixirc_paths: elixirc_paths(Mix.env()),
      aliases: aliases(),
      preferred_cli_env: cli(),
      test_coverage: [tool: ExCoveralls]
    ]
  end

  def application do
    [extra_applications: [:logger]]
  end

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

  defp deps do
    [
      {:ecto, "~> 3.13"},
      {:ecto_sql, "~> 3.0"},
      {:geometry, "~> 1.2"},
      {:postgrex, ">= 0.0.0"},
      {:exqlite, "~> 0.32"},
      {:ecto_sqlite3, "~> 0.21"},
      {:myxql, "~> 0.9.0", optional: true},

      # dev
      {:credo, "~> 1.0", only: [:dev, :test]},
      {:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false},
      {:excoveralls, "~> 0.14", only: :test, runtime: false},
      {:igniter, "~> 0.6", only: [:dev, :test]},
      {:ex_doc, ">= 0.0.0", only: :dev, runtime: false},

      # testing
      {:geo, "~> 4.0", only: [:test]},
      {:mix_test_watch, "~> 1.3", only: [:dev, :test], runtime: false}
    ]
  end

  def cli do
    [
      preferred_envs: [
        coveralls: :test,
        "coveralls.detail": :test,
        "coveralls.github": :test,
        "coveralls.html": :test,
        "test.watch": :test
      ]
    ]
  end

  defp package do
    [
      description:
        "Spatial databases and GIS SQL functions. Currently supports PostGIS, Spatialite, MySQL, MariaDB, and Geopackage.",
      files: ["lib", "mix.exs", "README.md", "CHANGELOG.md"],
      maintainers: ["Aaron Seigo"],
      licenses: ["MIT"],
      links: %{"GitHub" => @source_url}
    ]
  end

  defp docs do
    [
      extras: ["CHANGELOG.md", "README.md"],
      main: "readme",
      source_url: @source_url,
      source_ref: "v#{@version}",
      formatters: ["html"],
      groups_for_modules: [
        "Ecto Types": [~r/GeoSQL.Geometry.*/, GeoSQL.Int4],
        "SQL/MM": [~r/GeoSQL.MM.*/],
        "Non-Standard": [~r/GeoSQL.Common.*/],
        PostGIS: [~r/GeoSQL.PostGIS.*/],
        SpatiaLite: [~r/GeoSQL.SpatiaLite.*/],
        Utilities: [~r/GeoSQL.*Utils/]
      ]
    ]
  end

  # TODO: would be nice to find a way to get this from the test config.
  defp dynamic_test_repos(command) do
    command_args =
      (System.get_env("GEOSQL_TEST_BACKENDS") || "pgsql,sqlite3,mysql")
      |> String.split(",")
      |> Enum.reduce(["--quiet"], fn backend, acc ->
        case backend do
          "pgsql" -> ["GeoSQL.Test.PostGIS.Repo" | acc]
          "mysql" -> ["GeoSQL.Test.MySQL.Repo" | acc]
          "sqlite3" -> ["GeoSQL.Test.SpatiaLite.Repo" | acc]
        end
      end)
      |> Enum.reverse()

    "#{command} #{Enum.join(command_args, " -r ")}"
  end

  defp aliases do
    [
      test: [
        dynamic_test_repos("ecto.create"),
        dynamic_test_repos("ecto.migrate"),
        "test",
        dynamic_test_repos("ecto.drop")
      ]
    ]
  end
end