mix.exs (4989B)
1 defmodule EctoSQL.MixProject do 2 use Mix.Project 3 4 @source_url "https://github.com/elixir-ecto/ecto_sql" 5 @version "3.9.0" 6 @adapters ~w(pg myxql tds) 7 8 def project do 9 [ 10 app: :ecto_sql, 11 version: @version, 12 elixir: "~> 1.10", 13 deps: deps(), 14 test_paths: test_paths(System.get_env("ECTO_ADAPTER")), 15 xref: [ 16 exclude: [ 17 MyXQL, 18 Ecto.Adapters.MyXQL.Connection, 19 Postgrex, 20 Ecto.Adapters.Postgres.Connection, 21 Tds, 22 Tds.Ecto.UUID, 23 Ecto.Adapters.Tds.Connection 24 ] 25 ], 26 27 # Custom testing 28 aliases: [ 29 "test.all": ["test", "test.adapters", "test.as_a_dep"], 30 "test.adapters": &test_adapters/1, 31 "test.as_a_dep": &test_as_a_dep/1 32 ], 33 preferred_cli_env: ["test.all": :test, "test.adapters": :test], 34 35 # Hex 36 description: "SQL-based adapters for Ecto and database migrations", 37 package: package(), 38 39 # Docs 40 name: "Ecto SQL", 41 docs: docs() 42 ] 43 end 44 45 def application do 46 [ 47 extra_applications: [:logger, :eex], 48 env: [postgres_map_type: "jsonb"], 49 mod: {Ecto.Adapters.SQL.Application, []} 50 ] 51 end 52 53 defp deps do 54 [ 55 ecto_dep(), 56 {:telemetry, "~> 0.4.0 or ~> 1.0"}, 57 58 # Drivers 59 {:db_connection, "~> 2.5 or ~> 2.4.1"}, 60 postgrex_dep(), 61 myxql_dep(), 62 tds_dep(), 63 64 # Bring something in for JSON during tests 65 {:jason, ">= 0.0.0", only: [:test, :docs]}, 66 67 # Docs 68 {:ex_doc, "~> 0.21", only: :docs}, 69 70 # Benchmarks 71 {:benchee, "~> 0.11.0", only: :bench}, 72 {:benchee_json, "~> 0.4.0", only: :bench} 73 ] 74 end 75 76 defp ecto_dep do 77 if path = System.get_env("ECTO_PATH") do 78 {:ecto, path: path} 79 else 80 {:ecto, "~> 3.9.0"} 81 end 82 end 83 84 defp postgrex_dep do 85 if path = System.get_env("POSTGREX_PATH") do 86 {:postgrex, path: path} 87 else 88 {:postgrex, "~> 0.16.0 or ~> 1.0", optional: true} 89 end 90 end 91 92 defp myxql_dep do 93 if path = System.get_env("MYXQL_PATH") do 94 {:myxql, path: path} 95 else 96 {:myxql, "~> 0.6.0", optional: true} 97 end 98 end 99 100 defp tds_dep do 101 if path = System.get_env("TDS_PATH") do 102 {:tds, path: path} 103 else 104 {:tds, "~> 2.1.1 or ~> 2.2", optional: true} 105 end 106 end 107 108 defp test_paths(adapter) when adapter in @adapters, do: ["integration_test/#{adapter}"] 109 defp test_paths(nil), do: ["test"] 110 defp test_paths(other), do: raise("unknown adapter #{inspect(other)}") 111 112 defp package do 113 [ 114 maintainers: ["Eric Meadows-Jönsson", "José Valim", "James Fish", "Michał Muskała"], 115 licenses: ["Apache-2.0"], 116 links: %{"GitHub" => @source_url}, 117 files: 118 ~w(.formatter.exs mix.exs README.md CHANGELOG.md lib) ++ 119 ~w(integration_test/sql integration_test/support) 120 ] 121 end 122 123 defp test_as_a_dep(args) do 124 IO.puts("==> Compiling ecto_sql from a dependency") 125 File.rm_rf!("tmp/as_a_dep") 126 File.mkdir_p!("tmp/as_a_dep") 127 128 File.cd!("tmp/as_a_dep", fn -> 129 File.write!("mix.exs", """ 130 defmodule DepsOnEctoSQL.MixProject do 131 use Mix.Project 132 133 def project do 134 [ 135 app: :deps_on_ecto_sql, 136 version: "0.0.1", 137 deps: [{:ecto_sql, path: "../.."}] 138 ] 139 end 140 end 141 """) 142 143 mix_cmd_with_status_check(["do", "deps.get,", "compile", "--force" | args]) 144 end) 145 end 146 147 defp test_adapters(args) do 148 for adapter <- @adapters, do: env_run(adapter, args) 149 end 150 151 defp env_run(adapter, args) do 152 IO.puts("==> Running tests for ECTO_ADAPTER=#{adapter} mix test") 153 154 mix_cmd_with_status_check( 155 ["test", ansi_option() | args], 156 env: [{"ECTO_ADAPTER", adapter}] 157 ) 158 end 159 160 defp ansi_option do 161 if IO.ANSI.enabled?(), do: "--color", else: "--no-color" 162 end 163 164 defp mix_cmd_with_status_check(args, opts \\ []) do 165 {_, res} = System.cmd("mix", args, [into: IO.binstream(:stdio, :line)] ++ opts) 166 167 if res > 0 do 168 System.at_exit(fn _ -> exit({:shutdown, 1}) end) 169 end 170 end 171 172 defp docs do 173 [ 174 main: "Ecto.Adapters.SQL", 175 source_ref: "v#{@version}", 176 canonical: "http://hexdocs.pm/ecto_sql", 177 source_url: @source_url, 178 extras: ["CHANGELOG.md"], 179 skip_undefined_reference_warnings_on: ["CHANGELOG.md"], 180 groups_for_modules: [ 181 # Ecto.Adapters.SQL, 182 # Ecto.Adapters.SQL.Sandbox, 183 # Ecto.Migration, 184 # Ecto.Migrator, 185 186 "Built-in adapters": [ 187 Ecto.Adapters.MyXQL, 188 Ecto.Adapters.Tds, 189 Ecto.Adapters.Postgres 190 ], 191 "Adapter specification": [ 192 Ecto.Adapter.Migration, 193 Ecto.Adapter.Structure, 194 Ecto.Adapters.SQL.Connection, 195 Ecto.Migration.Command, 196 Ecto.Migration.Constraint, 197 Ecto.Migration.Index, 198 Ecto.Migration.Reference, 199 Ecto.Migration.Table 200 ] 201 ] 202 ] 203 end 204 end