Skip to content

Commit 7c4516f

Browse files
author
José Valim
committed
Do not access another task directly, use Mix.Rebar module instead
1 parent 65cc780 commit 7c4516f

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

lib/mix/lib/mix/rebar.ex

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
defmodule Mix.Rebar do
22
@moduledoc false
3+
@local_rebar_name "rebar"
34

5+
# Make Mix.Rebar work like a project so we can push it into the stack.
46
@doc false
57
def project, do: []
68

79
@doc """
8-
Loads the rebar.config and evaluates rebar.config.script if it exists in the
9-
given directory.
10+
Return the path to the local copy of rebar. Used when building deps.
11+
"""
12+
def local_rebar_path, do: Path.join(Mix.Utils.mix_home, @local_rebar_name)
13+
14+
@doc """
15+
Loads the rebar.config and evaluates rebar.config.script if it
16+
exists in the given directory.
1017
"""
1118
def load_config(dir) do
1219
config_path = Path.join(dir, "rebar.config")

lib/mix/lib/mix/tasks/deps.compile.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ defmodule Mix.Tasks.Deps.Compile do
137137
File.regular?("./rebar") ->
138138
Path.join(File.cwd!, "rebar")
139139

140-
File.regular?(Mix.Tasks.Local.Rebar.local_rebar_path) ->
141-
Mix.Tasks.Local.Rebar.local_rebar_path
140+
File.regular?(Mix.Rebar.local_rebar_path) ->
141+
Mix.Rebar.local_rebar_path
142142

143143
System.find_executable("rebar") ->
144144
"rebar"
@@ -152,7 +152,7 @@ defmodule Mix.Tasks.Deps.Compile do
152152
"dependency #{app}, please ensure rebar is available"
153153
end
154154
Mix.Task.run "local.rebar", []
155-
Mix.Tasks.Local.Rebar.local_rebar_path
155+
Mix.Tasks.local_rebar_path
156156
end
157157
end
158158

lib/mix/lib/mix/tasks/local.rebar.ex

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ defmodule Mix.Tasks.Local.Rebar do
33

44
import Mix.Generator, only: [create_file: 2]
55

6-
@rebar_url "https://github.com/downloads/basho/rebar/rebar"
7-
@local_rebar_name "rebar"
8-
9-
@shortdoc "Install rebar locally"
6+
@rebar_url "https://github.com/downloads/basho/rebar/rebar"
7+
@shortdoc "Install rebar locally"
108

119
@moduledoc """
1210
Fetch a copy of rebar from the given path or url, defaulting to
@@ -16,12 +14,6 @@ defmodule Mix.Tasks.Local.Rebar do
1614
This version of rebar will be used as required by mix deps.compile
1715
"""
1816

19-
@doc """
20-
Return the path to the local copy of rebar. Used when building deps
21-
"""
22-
def local_rebar_path, do: Path.join(local_rebar_dir, @local_rebar_name)
23-
defp local_rebar_dir, do: Mix.Utils.mix_home
24-
2517
def run(argv) do
2618
{ _, argv } = OptionParser.parse(argv)
2719
do_install(case argv do
@@ -32,7 +24,8 @@ defmodule Mix.Tasks.Local.Rebar do
3224

3325
defp do_install(path) do
3426
rebar = Mix.Utils.read_path(path)
35-
File.mkdir_p! local_rebar_dir
27+
local_rebar_path = Mix.Rebar.local_rebar_path
28+
File.mkdir_p! Path.dirname(local_rebar_path)
3629
create_file local_rebar_path, rebar
3730
:file.change_mode local_rebar_path, 0755
3831
end

0 commit comments

Comments
 (0)