diff options
author | Olafur Arason <olafura@olafura.com> | 2019-08-08 03:59:43 -0400 |
---|---|---|
committer | Fernando Tapia Rico <fertapric@gmail.com> | 2019-08-08 09:59:43 +0200 |
commit | 52a8795d8647c413aeeee01d6343206f21afa6e9 (patch) | |
tree | ccdf4c117568e33768b5c0d6ba4a4f6647b28e13 | |
parent | 95e637aaa8f2fd363b19bfd6acbeacb3c6f81faa (diff) | |
download | elixir-52a8795d8647c413aeeee01d6343206f21afa6e9.tar.gz |
Allow mix deps.compile to ignore umbrella apps (#9273)
This addresses the problem outlined in
https://github.com/elixir-lang/elixir/issues/7519
`mix deps.compile` can be a good way of caching builds
in a CI environment. Also it's good contain the warnings of the `mix
deps.compile` from the ones of `mix compile`.
-rw-r--r-- | lib/mix/lib/mix/tasks/deps.compile.ex | 19 | ||||
-rw-r--r-- | lib/mix/test/mix/tasks/deps_test.exs | 12 |
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/mix/lib/mix/tasks/deps.compile.ex b/lib/mix/lib/mix/tasks/deps.compile.ex index 62bc70f55..eb8cf525a 100644 --- a/lib/mix/lib/mix/tasks/deps.compile.ex +++ b/lib/mix/lib/mix/tasks/deps.compile.ex @@ -29,9 +29,12 @@ defmodule Mix.Tasks.Deps.Compile do date. This is to allow parts of the dependency tree to be recompiled without propagating those changes upstream. To ensure `b` is included in the compilation step, pass `--include-children`. + + If you want to exclude umbrella applications from building pass + `--skip-umbrella-children`. """ - @switches [include_children: :boolean, force: :boolean] + @switches [include_children: :boolean, force: :boolean, skip_umbrella_children: :boolean] @impl true def run(args) do @@ -58,11 +61,14 @@ defmodule Mix.Tasks.Deps.Compile do def compile(deps, options \\ []) do shell = Mix.shell() config = Mix.Project.deps_config() + skip_umbrella_children = Keyword.get(options, :skip_umbrella_children) Mix.Task.run("deps.precompile") compiled = - Enum.map(deps, fn %Mix.Dep{app: app, status: status, opts: opts, scm: scm} = dep -> + deps + |> reject_umbrella_children(skip_umbrella_children) + |> Enum.map(fn %Mix.Dep{app: app, status: status, opts: opts, scm: scm} = dep -> check_unavailable!(app, status) maybe_clean(dep, options) @@ -310,4 +316,13 @@ defmodule Mix.Tasks.Deps.Compile do defp makefile_win?(%Mix.Dep{opts: opts}) do File.regular?(Path.join(opts[:dest], "Makefile.win")) end + + defp reject_umbrella_children(deps, true) do + deps + |> Enum.reject(fn %{opts: opts} -> Keyword.get(opts, :from_umbrella) == true end) + end + + defp reject_umbrella_children(deps, _) do + deps + end end diff --git a/lib/mix/test/mix/tasks/deps_test.exs b/lib/mix/test/mix/tasks/deps_test.exs index bfac0fd9d..ccb6c49e9 100644 --- a/lib/mix/test/mix/tasks/deps_test.exs +++ b/lib/mix/test/mix/tasks/deps_test.exs @@ -191,6 +191,18 @@ defmodule Mix.Tasks.DepsTest do end) end + test "doesn't compile any umbrella apps if --skip-umbrella-children given" do + in_fixture("umbrella_dep/deps/umbrella", fn -> + Mix.Project.in_project(:umbrella, ".", fn _ -> + refute File.exists?("_build/dev/lib/foo/ebin") + refute File.exists?("_build/dev/lib/bar/ebin") + Mix.Tasks.Deps.Compile.run(["--skip-umbrella-children"]) + refute File.exists?("_build/dev/lib/foo/ebin") + refute File.exists?("_build/dev/lib/bar/ebin") + end) + end) + end + ## deps.loadpaths test "checks list of dependencies and their status with success" do |