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
71
71
@ doc false
72
72
def deps_config ( config // config ( ) ) do
73
73
[ build_path: build_path ( config ) ,
74
+ builds_per_environment: config [ :builds_per_environment ] ,
74
75
deps_path: deps_path ( config ) ]
75
76
end
76
77
@@ -186,9 +187,21 @@ defmodule Mix.Project do
186
187
Mix.Project.build_path
187
188
#=> "/path/to/project/_build/shared"
188
189
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
+
189
198
"""
190
199
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
192
205
end
193
206
194
207
@ doc """
@@ -309,7 +322,8 @@ defmodule Mix.Project do
309
322
end
310
323
311
324
defp default_config do
312
- [ default_task: "run" ,
325
+ [ builds_per_environment: false ,
326
+ default_task: "run" ,
313
327
deps: [ ] ,
314
328
deps_path: "deps" ,
315
329
elixirc_exts: [ :ex ] ,
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ defmodule Mix.Tasks.Compile.ElixirTest do
13
13
:ok
14
14
end
15
15
16
- test "compile a project without mixfile " do
16
+ test "compiles a project" do
17
17
in_fixture "no_mixfile" , fn ->
18
18
Mix.Tasks.Compile.Elixir . run [ ]
19
19
@@ -27,6 +27,24 @@ defmodule Mix.Tasks.Compile.ElixirTest do
27
27
end
28
28
end
29
29
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
+
30
48
test "does not write beam down on failures" do
31
49
import ExUnit.CaptureIO
32
50
You can’t perform that action at this time.
0 commit comments