Created
July 15, 2014 18:01
-
-
Save khia/5556248c3e9212f329e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat apps/bexng/mix.exs | |
defmodule Bexng.Mixfile do | |
use Bexng.Project | |
def project do | |
[ app: :bexng, | |
version: "0.0.1", | |
elixir: ">= 0.14.3-dev", | |
deps: deps ] | |
end | |
# Configuration for the OTP application | |
def application do | |
[ | |
## decimal is required until https://github.com/meh/decimex/pull/3 is merged | |
applications: ~w(inets gproc exmig exdbi_pgsql lager poolboy barrel jsex exlogger folsom cowboy decimex decimal validatex)a ++ applications(Mix.env), | |
mod: {Bexng.App, []}, | |
env: [], | |
] | |
end | |
defp applications(:dev), do: ~w(runtime_tools)a | |
defp applications(_), do: ~w()a | |
defp deps do | |
[ | |
{:gproc, github: "uwiger/gproc"}, | |
{:exmig, github: "khia/exmig"}, | |
{:exdbi_pgsql, github: "khia/exdbi_pgsql"}, | |
{:epgsql, github: "spawngrid/epgsql", override: true}, | |
{:lager, github: "basho/lager"}, | |
{:poolboy, github: "devinus/poolboy"}, | |
{:barrel, github: "spawngrid/barrel"}, | |
{:jsex, github: "talentdeficit/jsex"}, | |
{:exlogger, github: "khia/exlogger"}, | |
{:decimex, github: "khia/decimex"}, | |
{:folsom, github: "boundary/folsom"}, | |
{:validatex, github: "khia/validatex"}, | |
{:cowboy, github: "spawngrid/cowboy", branch: "proxy", override: true}, | |
] ++ deps(Mix.env) | |
end | |
defp deps(:dev) do | |
[] | |
end | |
defp deps(:test) do | |
[ | |
{:bexng_test, in_umbrella: true}, | |
] | |
end | |
defp deps(_) do | |
[ | |
] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat mix.exs | |
defmodule Bexng.Project do | |
@moduledoc """ | |
Bexng.Project is a drop-in replacement for Mix.Project to be used within | |
the Bexng project. | |
It is main purpose is to automagically setup correct `deps_path` and | |
`lockfile` options for all applications in the project. | |
## Example | |
defmodule Bexng.Something.Mixfile do | |
use Bexng.Project | |
def project do | |
[ app: :something, | |
deps: deps ] | |
end | |
defp deps do | |
[] | |
end | |
end | |
""" | |
@dir __DIR__ | |
def root_dir, do: @dir | |
defmacro __using__(_) do | |
quote do | |
use Mix.Project | |
@before_compile Bexng.Project | |
defp project_defaults do | |
[ | |
deps_path: Path.join(unquote(@dir), "deps"), | |
lockfile: Path.join(unquote(@dir), "mix.lock"), | |
elixirc_watch_exts: [:ex, :eex, :sql], | |
build_per_environment: true, | |
] ++ project_defaults(Mix.env) | |
end | |
defp project_defaults(:test), do: [elixirc_paths: ["lib", "test/modules"]] | |
defp project_defaults(_), do: [] | |
defoverridable project_defaults: 0 | |
end | |
end | |
defmacro __before_compile__(_) do | |
quote do | |
defoverridable project: 0 | |
def project do | |
config = super | |
Keyword.merge(project_defaults, config) | |
end | |
end | |
end | |
end | |
defmodule Bexng.Umbrella.Mixfile do | |
use Bexng.Project | |
def project do | |
[ apps_path: "apps", | |
deps: deps ] ++ project(Mix.env) | |
end | |
def project(:test) do | |
selective = System.get_env("BEXNG_SELECTIVE") | |
if selective && selective != "" do | |
[ apps: String.split(selective) |> Enum.map(&:erlang.binary_to_atom/1) ] | |
else | |
[] | |
end | |
end | |
def project(_), do: [] | |
defp deps do | |
[ | |
{:relex, github: "khia/relex"}, | |
] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment