1
1
defrecord Mix.Dep , [ scm: nil , app: nil , requirement: nil , status: nil , opts: nil ,
2
- project: nil , deps: [ ] , rebar : nil ] do
2
+ deps: [ ] , source: nil , manager : nil ] do
3
3
@ moduledoc """
4
4
This is a record that keeps information about your project
5
5
dependencies. It keeps:
@@ -9,7 +9,9 @@ defrecord Mix.Dep, [ scm: nil, app: nil, requirement: nil, status: nil, opts: ni
9
9
* requirements - a binary or regexp with the deps requirement;
10
10
* status - the current status of dependency, check `Mix.Deps.format_status/1` for more info;
11
11
* opts - the options given by the developer
12
- * project - the Mix.Project for the dependency
12
+ * source - any possible configuration associated with the manager field,
13
+ rebar.config for rebar or the Mix.Project for Mix
14
+ * manager - the project management, possible values: :rebar / :mix / nil
13
15
"""
14
16
end
15
17
@@ -95,7 +97,18 @@ defmodule Mix.Deps do
95
97
"""
96
98
def in_dependency ( dep , post_config // [ ] , fun )
97
99
98
- def in_dependency ( Mix.Dep [ app : app , opts: opts , rebar: nil ] , post_config , fun ) do
100
+ def in_dependency ( Mix.Dep [ manager : :rebar , opts: opts ] , post_config , fun ) do
101
+ # Use post_config for rebar deps
102
+ Mix.Project . post_config ( post_config )
103
+ Mix.Project . push ( Mix.Rebar )
104
+ try do
105
+ File . cd! ( opts [ :dest ] , fn -> fun . ( nil ) end )
106
+ after
107
+ Mix.Project . pop
108
+ end
109
+ end
110
+
111
+ def in_dependency ( Mix.Dep [ app : app , opts: opts ] , post_config , fun ) do
99
112
env = opts [ :env ] || :prod
100
113
old_env = Mix . env
101
114
@@ -107,17 +120,6 @@ defmodule Mix.Deps do
107
120
end
108
121
end
109
122
110
- def in_dependency ( Mix.Dep [ opts : opts ] , post_config , fun ) do
111
- # Use post_config for rebar deps
112
- Mix.Project . post_config ( post_config )
113
- Mix.Project . push ( Mix.Rebar )
114
- try do
115
- File . cd! ( opts [ :dest ] , fn -> fun . ( nil ) end )
116
- after
117
- Mix.Project . pop
118
- end
119
- end
120
-
121
123
@ doc """
122
124
Formats the status of a dependency.
123
125
"""
@@ -220,8 +222,8 @@ defmodule Mix.Deps do
220
222
@ doc """
221
223
Returns all compile paths for the dependency.
222
224
"""
223
- def compile_paths ( Mix.Dep [ app : app , opts: opts ] = dep ) do
224
- if mix? ( dep ) do
225
+ def compile_paths ( Mix.Dep [ app : app , opts: opts , manager: manager ] ) do
226
+ if manager == : mix do
225
227
Mix.Project . in_project app , opts [ :dest ] , fn _ ->
226
228
Mix.Project . compile_paths
227
229
end
@@ -233,37 +235,38 @@ defmodule Mix.Deps do
233
235
@ doc """
234
236
Returns all load paths for the dependency.
235
237
"""
236
- def load_paths ( Mix.Dep [ app : app , opts: opts ] = dep ) do
237
- cond do
238
- mix? ( dep ) ->
239
- paths = Mix.Project . in_project app , opts [ :dest ] , fn _ ->
240
- Mix.Project . load_paths
241
- end
242
- Enum . uniq paths
243
- rebar? ( dep ) ->
244
- # Add root dir and all sub dirs with ebin/ directory
245
- [ opts [ :dest ] | ( dep . rebar [ :sub_dirs ] || [ ] ) ]
246
- |> Enum . map ( Path . wildcard ( & 1 ) )
247
- |> List . concat
248
- |> Enum . map ( fn path -> Path . join ( [ opts [ :dest ] , path , "ebin" ] ) end )
249
- |> Enum . filter ( File . dir? ( & 1 ) )
250
- true ->
251
- [ Path . join ( opts [ :dest ] , "ebin" ) ]
238
+ def load_paths ( Mix.Dep [ manager : :mix , app: app , opts: opts ] ) do
239
+ paths = Mix.Project . in_project app , opts [ :dest ] , fn _ ->
240
+ Mix.Project . load_paths
252
241
end
242
+ Enum . uniq paths
243
+ end
244
+
245
+ def load_paths ( Mix.Dep [ manager : :rebar , opts: opts , source: source ] ) do
246
+ # Add root dir and all sub dirs with ebin/ directory
247
+ [ opts [ :dest ] | ( source [ :sub_dirs ] || [ ] ) ]
248
+ |> Enum . map ( Path . wildcard ( & 1 ) )
249
+ |> List . concat
250
+ |> Enum . map ( fn path -> Path . join ( [ opts [ :dest ] , path , "ebin" ] ) end )
251
+ |> Enum . filter ( File . dir? ( & 1 ) )
252
+ end
253
+
254
+ def load_paths ( Mix.Dep [ manager : nil , opts: opts ] ) do
255
+ [ Path . join ( opts [ :dest ] , "ebin" ) ]
253
256
end
254
257
255
258
@ doc """
256
259
Returns true if dependency is a mix project.
257
260
"""
258
- def mix? ( dep ) do
259
- dep . project != nil
261
+ def mix? ( Mix.Dep [ manager : manager ] ) do
262
+ manager == :mix
260
263
end
261
264
262
265
@ doc """
263
266
Returns true if dependency is a rebar project.
264
267
"""
265
- def rebar? ( dep ) do
266
- dep . rebar != nil
268
+ def rebar? ( Mix.Dep [ manager : manager ] ) do
269
+ manager == :rebar
267
270
end
268
271
269
272
@ doc """
0 commit comments