@@ -38,8 +38,9 @@ defmodule Mix.Tasks.Xref do
38
38
$ mix xref trace lib/my_app/router.ex --label compile
39
39
40
40
If you have an umbrella application, we also recommend using the
41
- `--include-siblings` flag to see the dependencies on other
42
- umbrella applications.
41
+ `--include-siblings` flag to see the dependencies from sibling
42
+ applications. The `trace` command is not currently supported at the
43
+ umbrella root.
43
44
44
45
### Example
45
46
@@ -222,6 +223,12 @@ defmodule Mix.Tasks.Xref do
222
223
lib/a.ex
223
224
└── lib/b.ex (compile)
224
225
226
+ If you have an umbrella application, we also recommend using the
227
+ `--include-siblings` flag to see the dependencies from sibling
228
+ applications. When invoked at the umbrella root, the `graph`
229
+ command will list all files from all umbrella children, without
230
+ any namespacing.
231
+
225
232
### Dependency types
226
233
227
234
Elixir tracks three types of dependencies between modules: compile,
@@ -289,22 +296,18 @@ defmodule Mix.Tasks.Xref do
289
296
290
297
@ impl true
291
298
def run ( args ) do
292
- if Mix.Project . umbrella? ( ) do
293
- Mix . raise (
294
- "mix xref is not supported in the umbrella root. Please run it inside the umbrella applications instead"
295
- )
296
- end
297
-
298
299
Mix.Task . run ( "compile" , args )
299
300
Mix.Task . reenable ( "xref" )
300
301
301
302
{ opts , args } = OptionParser . parse! ( args , strict: @ switches )
302
303
303
304
case args do
304
305
[ "callers" , module ] ->
306
+ no_umbrella! ( "callers" )
305
307
handle_callers ( module , opts )
306
308
307
309
[ "trace" , file ] ->
310
+ no_umbrella! ( "trace" )
308
311
handle_trace ( file , opts )
309
312
310
313
[ "graph" ] ->
@@ -327,6 +330,14 @@ defmodule Mix.Tasks.Xref do
327
330
end
328
331
end
329
332
333
+ defp no_umbrella! ( task ) do
334
+ if Mix.Project . umbrella? ( ) do
335
+ Mix . raise (
336
+ "mix xref #{ task } is not supported in the umbrella root. Please run it inside the umbrella applications instead"
337
+ )
338
+ end
339
+ end
340
+
330
341
@ doc """
331
342
Returns a list of information of all the runtime function calls in the project.
332
343
@@ -1058,12 +1069,18 @@ defmodule Mix.Tasks.Xref do
1058
1069
1059
1070
defp manifests ( opts ) do
1060
1071
siblings =
1061
- if opts [ :include_siblings ] do
1062
- for % { scm: Mix.SCM.Path , opts: opts } <- Mix.Dep . cached ( ) ,
1063
- opts [ :in_umbrella ] ,
1064
- do: Path . join ( [ opts [ :build ] , ".mix" , @ manifest ] )
1065
- else
1066
- [ ]
1072
+ cond do
1073
+ Mix.Project . umbrella? ( ) ->
1074
+ for % { opts: opts } <- Mix.Dep.Umbrella . cached ( ) ,
1075
+ do: Path . join ( [ opts [ :build ] , ".mix" , @ manifest ] )
1076
+
1077
+ opts [ :include_siblings ] ->
1078
+ for % { scm: Mix.SCM.Path , opts: opts } <- Mix.Dep . cached ( ) ,
1079
+ opts [ :in_umbrella ] ,
1080
+ do: Path . join ( [ opts [ :build ] , ".mix" , @ manifest ] )
1081
+
1082
+ true ->
1083
+ [ ]
1067
1084
end
1068
1085
1069
1086
[ Path . join ( Mix.Project . manifest_path ( ) , @ manifest ) | siblings ]
0 commit comments