File tree Expand file tree Collapse file tree 2 files changed +35
-3
lines changed
Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ defmodule Mix.Project do
7171 @ doc false
7272 def deps_config ( config // config ( ) ) do
7373 [ build_path: build_path ( config ) ,
74+ builds_per_environment: config [ :builds_per_environment ] ,
7475 deps_path: deps_path ( config ) ]
7576 end
7677
@@ -186,9 +187,21 @@ defmodule Mix.Project do
186187 Mix.Project.build_path
187188 #=> "/path/to/project/_build/shared"
188189
190+ If :builds_per_environment is set to true, it
191+ will create a new build per environment:
192+
193+ Mix.env
194+ #=> :dev
195+ Mix.Project.build_path
196+ #=> "/path/to/project/_build/dev"
197+
189198 """
190199 def build_path ( config // config ( ) ) do
191- config [ :build_path ] || Path . expand ( "_build/shared" )
200+ config [ :build_path ] || if config [ :builds_per_environment ] do
201+ Path . expand ( "_build/#{ Mix . env } " )
202+ else
203+ Path . expand ( "_build/shared" )
204+ end
192205 end
193206
194207 @ doc """
@@ -309,7 +322,8 @@ defmodule Mix.Project do
309322 end
310323
311324 defp default_config do
312- [ default_task: "run" ,
325+ [ builds_per_environment: false ,
326+ default_task: "run" ,
313327 deps: [ ] ,
314328 deps_path: "deps" ,
315329 elixirc_exts: [ :ex ] ,
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ defmodule Mix.Tasks.Compile.ElixirTest do
1313 :ok
1414 end
1515
16- test "compile a project without mixfile " do
16+ test "compiles a project" do
1717 in_fixture "no_mixfile" , fn ->
1818 Mix.Tasks.Compile.Elixir . run [ ]
1919
@@ -27,6 +27,24 @@ defmodule Mix.Tasks.Compile.ElixirTest do
2727 end
2828 end
2929
30+ test "compiles a project with per environment build" do
31+ Mix.Project . pop
32+ Mix.ProjectStack . post_config [ builds_per_environment: true ]
33+ Mix.Project . push MixTest.Case.Sample
34+
35+ in_fixture "no_mixfile" , fn ->
36+ Mix.Tasks.Compile.Elixir . run [ ]
37+
38+ assert File . regular? ( "_build/dev/lib/sample/ebin/Elixir.A.beam" )
39+ assert File . regular? ( "_build/dev/lib/sample/ebin/Elixir.B.beam" )
40+ assert File . regular? ( "_build/dev/lib/sample/ebin/Elixir.C.beam" )
41+
42+ assert_received { :mix_shell , :info , [ "Compiled lib/a.ex" ] }
43+ assert_received { :mix_shell , :info , [ "Compiled lib/b.ex" ] }
44+ assert_received { :mix_shell , :info , [ "Compiled lib/c.ex" ] }
45+ end
46+ end
47+
3048 test "does not write beam down on failures" do
3149 import ExUnit.CaptureIO
3250
You can’t perform that action at this time.
0 commit comments