summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ebin/rebar.app20
-rw-r--r--src/rebar.app.src1
-rw-r--r--src/rebar_core.erl8
-rw-r--r--src/rebar_plugins.erl12
-rw-r--r--src/rebar_prv_do.erl45
-rw-r--r--src/rebar_prv_update.erl14
6 files changed, 75 insertions, 25 deletions
diff --git a/ebin/rebar.app b/ebin/rebar.app
index 967eb8e..831567b 100644
--- a/ebin/rebar.app
+++ b/ebin/rebar.app
@@ -8,9 +8,10 @@
rebar_app_info,rebar_app_utils,rebar_base_compiler,
rebar_config,rebar_core,rebar_erlc_compiler,
rebar_erlydtl_compiler,rebar_fetch,rebar_file_utils,
- rebar_log,rebar_otp_app,rebar_packages,rebar_provider,
- rebar_prv_app_discovery,rebar_prv_compile,
- rebar_prv_deps,rebar_prv_escripter,rebar_prv_help,
+ rebar_log,rebar_otp_app,rebar_packages,rebar_plugins,
+ rebar_provider,rebar_prv_app_discovery,
+ rebar_prv_compile,rebar_prv_deps,rebar_prv_do,
+ rebar_prv_escripter,rebar_prv_help,
rebar_prv_install_deps,rebar_prv_lock,rebar_prv_new,
rebar_prv_packages,rebar_prv_release,rebar_prv_shell,
rebar_prv_tar,rebar_prv_update,rebar_prv_version,
@@ -22,9 +23,10 @@
tools,erlware_commons,relx,inets]},
{env,[{log_level,warn},
{providers,[rebar_prv_escripter,rebar_prv_deps,
- rebar_prv_lock,rebar_prv_install_deps,
- rebar_prv_packages,rebar_erlydtl_compiler,
- rebar_prv_compile,rebar_prv_app_discovery,
- rebar_prv_shell,rebar_prv_tar,rebar_prv_new,
- rebar_prv_update,rebar_prv_release,
- rebar_prv_version,rebar_prv_help]}]}]}.
+ rebar_prv_do,rebar_prv_lock,
+ rebar_prv_install_deps,rebar_prv_packages,
+ rebar_erlydtl_compiler,rebar_prv_compile,
+ rebar_prv_app_discovery,rebar_prv_shell,
+ rebar_prv_tar,rebar_prv_new,rebar_prv_update,
+ rebar_prv_release,rebar_prv_version,
+ rebar_prv_help]}]}]}.
diff --git a/src/rebar.app.src b/src/rebar.app.src
index 59f35ca..2e21351 100644
--- a/src/rebar.app.src
+++ b/src/rebar.app.src
@@ -23,6 +23,7 @@
%% any_dir processing modules
{providers, [rebar_prv_escripter,
rebar_prv_deps,
+ rebar_prv_do,
rebar_prv_lock,
rebar_prv_install_deps,
rebar_prv_packages,
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index 8732074..cb021e3 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -30,10 +30,6 @@
-include("rebar.hrl").
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
process_command(State, Command) ->
true = rebar_utils:expand_code_path(),
LibDirs = rebar_state:get(State, lib_dirs, ?DEFAULT_LIB_DIRS),
@@ -50,6 +46,10 @@ process_command(State, Command) ->
Conf1
end, State, TargetProviders).
+%% ===================================================================
+%% Internal functions
+%% ===================================================================
+
update_code_path([]) ->
no_change;
update_code_path(Paths) ->
diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl
new file mode 100644
index 0000000..0fdbc6d
--- /dev/null
+++ b/src/rebar_plugins.erl
@@ -0,0 +1,12 @@
+%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 et
+
+-module(rebar_plugins).
+
+-export([]).
+
+-include("rebar.hrl").
+
+%% ===================================================================
+%% Public API
+%% ===================================================================
diff --git a/src/rebar_prv_do.erl b/src/rebar_prv_do.erl
new file mode 100644
index 0000000..a2ac648
--- /dev/null
+++ b/src/rebar_prv_do.erl
@@ -0,0 +1,45 @@
+%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 et
+
+-module(rebar_prv_do).
+
+-behaviour(rebar_provider).
+
+-export([init/1,
+ do/1]).
+
+-include("rebar.hrl").
+
+-define(PROVIDER, do).
+-define(DEPS, []).
+
+%% ===================================================================
+%% Public API
+%% ===================================================================
+
+-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
+init(State) ->
+ State1 = rebar_state:add_provider(State, #provider{name = ?PROVIDER,
+ provider_impl = ?MODULE,
+ bare = false,
+ deps = ?DEPS,
+ example = "rebar3 do <task1>, <task2>, ...",
+ short_desc = "Higher order provider for running multiple tasks in a sequence.",
+ desc = "",
+ opts = []}),
+ {ok, State1}.
+
+-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error().
+do(State) ->
+ Tasks = args_to_tasks(rebar_state:command_args(State)),
+ State1 = lists:foldl(fun(TaskArgs, StateAcc) ->
+ [TaskStr | Args] = string:tokens(TaskArgs, " "),
+ Task = list_to_atom(TaskStr),
+ StateAcc1 = rebar_state:set(StateAcc, task, Task),
+ StateAcc2 = rebar_state:command_args(StateAcc1, Args),
+ rebar_core:process_command(StateAcc2, Task)
+ end, State, Tasks),
+ {ok, State1}.
+
+args_to_tasks(Args) ->
+ [string:strip(T) || T <- string:tokens(string:join(Args, " "), ",")].
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
index 9df8e60..e19041a 100644
--- a/src/rebar_prv_update.erl
+++ b/src/rebar_prv_update.erl
@@ -33,18 +33,8 @@ init(State) ->
do(State) ->
case rebar_state:command_args(State) of
[Name] ->
- ?INFO("Updating ~s~n", [Name]),
-
- DepsDir = rebar_prv_install_deps:get_deps_dir(State),
- Deps = rebar_state:get(State, deps, []),
- {_, _, Source} = lists:keyfind(list_to_atom(Name), 1, Deps),
- TargetDir = rebar_prv_install_deps:get_deps_dir(DepsDir, Name),
- rebar_fetch:update_source1(TargetDir, Source),
- State1 = rebar_state:set(State, locks, []),
- {ok, State2} = rebar_prv_install_deps:do(State1),
- {ok, State3} = rebar_prv_lock:do(State2),
- {ok, State4} = rebar_prv_compile:do(State3),
- {ok, State4};
+ ?ERROR("NOT IMPLEMENTED: Updating ~s~n", [Name]),
+ {ok, State};
[] ->
?INFO("Updating package index...~n", []),
Url = url(State),